anyone to examine my code

nokmaster
06-03-2005, 01:31 AM
i have a problem with my code because when i open a file... example Test.txt
1st and 2nd time the dialog well show i want only once to load a file...

Here:

Private Sub mnuLoadpm_Click()
Dim textline As String
On Error GoTo Canceled
Call GetIMEI
cdlg.Filter = "Permanent Memory (*.pm)|*.pm"
cdlg.ShowOpen
If InStr(LoadText(cdlg.FileName), "[208]") = 0 Then MsgBox "Error", vbCritical, "Error": Exit Sub
txtDATA1 = LoadText(cdlg.FileName)
Open cdlg.FileName For Input As #1
While Not EOF(1)
Line Input #1, textline
If textline = "[208]" Then
Line Input #1, textline
txtDATA1.Text = Split(textline, "=")(1)
Close #1
Exit Sub
End If
Wend
Close #1
Canceled:
End Sub

Public Sub GetIMEI()
Dim textline As String
On Error GoTo Canceled
cdlg.Filter = "Permanent Memory (*.pm)|*.pm"
cdlg.ShowOpen
If InStr(LoadText(cdlg.FileName), "[5]") = 0 Then MsgBox "Error", vbCritical, "Error": Exit Sub
txtIMEI = LoadText(cdlg.FileName)
Open cdlg.FileName For Input As #1
While Not EOF(1)
Line Input #1, textline
If textline = "[5]" Then
Line Input #1, textline
txtIMEI.Text = Split(textline, "=")(1)
Dim value1 As String
Dim value2 As String
Dim value3 As String
Dim value4 As String
Dim value5 As String
Dim value6 As String
Dim value7 As String
Dim value8 As String
Dim value9 As String
Dim value10 As String
Dim value11 As String
Dim value12 As String
Dim value13 As String
Dim value14 As String
Dim value15 As String
value1 = Mid(txtIMEI, 2, 1)
value2 = Mid(txtIMEI, 4, 1)
value3 = Mid(txtIMEI, 6, 1)
value4 = Mid(txtIMEI, 8, 1)
value5 = Mid(txtIMEI, 10, 1)
value6 = Mid(txtIMEI, 12, 1)
value7 = Mid(txtIMEI, 16, 1)
value8 = Mid(txtIMEI, 18, 1)
value9 = Mid(txtIMEI, 22, 1)
value10 = Mid(txtIMEI, 24, 1)
value11 = Mid(txtIMEI, 26, 1)
value12 = Mid(txtIMEI, 28, 1)
value13 = Mid(txtIMEI, 30, 1)
value14 = Mid(txtIMEI, 32, 1)
value15 = Mid(txtIMEI, 36, 1)
txtIMEI.Text = value1 & value2 & value3 & value4 & value5 & value6 & value7 & value8 & value9 & value10 & value11 & value12 & value13 & value14 & value15
Close #1
Exit Sub
End If
Wend
Close #1
Canceled:
End
End Sub

harzem
06-03-2005, 02:34 AM
i have a problem with my code because when i open a file... example Test.txt
1st and 2nd time the dialog well show i want only once to load a file...


I don't know whether is it my english problem or yours, but I couldn't understand your question. Can you clarify a bit?

nokmaster
06-03-2005, 02:59 AM
@harzem

yes... when i want to open a file like Example: Text.txt

when i load this file it's show twice the dialog box

kindly examine my code...

thanks....

spikey_richie
06-03-2005, 05:34 AM
In your first routine you're calling IMIE, which runs the same code as the routine you're calling it from. For this reason you have the following twice:


Open cdlg.FileName For Input As #1
While Not EOF(1)
Line Input #1, textline

MikeJ
06-03-2005, 10:34 AM
Not only that but the reason why you have the dialog box itself physically opening twice is because you have "cdlg.ShowOpen" running twice (for the reasons that spikey_richie) pointed out.

nokmaster
06-03-2005, 10:00 PM
so what should i do?

RoofRabbit
06-04-2005, 02:35 AM
You only need the open dialog box one time, just save the returned filename for later use.

nokmaster
06-04-2005, 04:15 AM
@RoofRabbit

how to do that? can u give an example...

thanks

regards

reboot
06-04-2005, 05:19 AM
You need an example of using a variable?

Dim s As String
s = cdlg.FileName :huh:

nokmaster
06-04-2005, 07:24 AM
@reboot

now i understand...

Thank you sir... :)

br,
nokmaster

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum