This article has been dead for over three months
You
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 byMenu Editor menu.
- After user fill the path, I will check the exist of it with method Dir like :
<pre><code>If Dir(ipPath) = "" Then</code></pre>
- I try to save the variable that user filled out with Open, Put, Close method like :
<pre><code>Open ipPath For Random As #1
Put #1, , sIP2
Close #1</code></pre>
- When I try to retrieve variable from TextBox control with Get method like this :
<pre><code>Get #1, , sIP2</code></pre>
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 :
2. And I made the one form as the main menu with Menu Editor and the code like this :
<pre><code>Type tLokPDF
sIP As String * 30
End Type</code></pre>
<pre><code>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</code></pre>
Thanks for attention....