ransomjulian 0 Newbie Poster

Hi.. All. Just to the point....

  • I'm working on inventory program, but I have no idea, some my code NOT WORK... just like that.. I repeat... NOT WORK. I usually use that method and always fine.

  • I'm a Newbie VB Developer for 3 years. For all that years I have no problem with Open method. But this time... It's really made me crazy... :(

The Point :

  • I want to browsing folder from network, so I plane to let user fill the location or path of the network folder in TextBox control that located in Frame control. This frame is triggered by Menu Editor menu.

  • After user fill the path, I will check the exist of it with method Dir like :

    If Dir(ipPath) = "" Then
    
  • I try to save the variable that user filled out with Open, Put, Close method like :

    Open ipPath For Random As #1
    Put #1, , sIP2
    Close #1
    
  • When I try to retrieve variable from TextBox control with Get method like this :

    Get #1, , sIP2
    

    I get the variable is still the default value : \pc22\docs.

As support information, I have my PC spec like this :

  • PC : HP Evo d220
  • OS : Windows XP Pro. SP2
  • APP : VB6 SP5 Ent. Edition

Other Software :

  • Visual Studio .NET 2003
  • .NET Framework 2

Why I get condition like this?
For detail, I have write my code like bellow.

  1. I wrote in my .bas file (Module) like this :

    Type tLokPDF
        sIP As String * 30
    End Type
    
  2. And I made the one form as the main menu with [B]Menu Editor[/B] and the code like this :

    Option Explicit
    
    Dim sIPForm
    Dim ipPath As String
    
    Private Sub cmdLokPDF_Click(Index As Integer)
        If Index = 0 Then
            If Trim(txtIP.Text) = "" Then
                MsgBox "Fill the field, do not let it blank.." & vbCrLf & vbCrLf & "Example :" & vbCrLf & "\\192.168.14.30\docs" & vbCrLf & " or " & vbCrLf & "\\pc22\docs" & vbCrLf & vbCrLf, vbExclamation
                txtIP.SelStart = 0: txtIP.SelLength = Len(txtIP.Text)
                txtIP.SetFocus
                Exit Sub
            End If
            Dim sIP2 As tLokPDF
            sIP2.sIP = Trim(sIPForm)
            Open ipPath For Random As #1
            Put #1, , sIP2
            Close #1
        End If
        fraLokPDF.Visible = False
    End Sub
    
    Private Sub Form_Load()
        ipPath = App.Path & "\set_ip_pdf.ini"
    End Sub
    
    Private Sub mn_2_Click()
        Frm2.Show 1
    End Sub
    
    Private Sub mn_3_Click()
        Frm3.Show 1
    End Sub
    
    Private Sub mn_4_Click()
        End
    End Sub
    
    Private Sub mn_option_lokpdf_Click()
        Dim sIP2 As tLokPDF
    
        If Dir(ipPath) = "" Then
            sIPForm = "\\pc22\docs"
        Else
            Open ipPath For Random As #1
            Get #1, , sIP2
            sIPForm = sIP2.sIP
            Close #1
        End If
    
        txtIP.Text = Trim(sIPForm)
        fraLokPDF.Visible = True
        txtIP.SetFocus
    End Sub
    
    Private Sub txtIP_Click()
        txtIP.SelStart = 0
        txtIP.SelLength = Len(txtIP.Text)
        txtIP.SetFocus
    End Sub
    
    Private Sub txtIP_KeyPress(KeyAscii As Integer)
        If KeyAscii = 13 Then Call cmdLokPDF_Click(0)
    End Sub
    

Thanks for attention....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.