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
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