954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

I can't retrieve my variable with Get method

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) = &quot;&quot; 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 :


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


<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) = &quot;&quot; Then
MsgBox &quot;Fill the field, do not let it blank..&quot; &amp; vbCrLf &amp; vbCrLf &amp; &quot;Example :&quot; &amp; vbCrLf &amp; &quot;\\192.168.14.30\docs&quot; &amp; vbCrLf &amp; &quot; or &quot; &amp; vbCrLf &amp; &quot;\\pc22\docs&quot; &amp; vbCrLf &amp; 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 &amp; &quot;\set_ip_pdf.ini&quot;
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) = &quot;&quot; Then
sIPForm = &quot;\\pc22\docs&quot;
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....

ransomjulian
Newbie Poster
1 post since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You