 |
 |

05-08-2003, 08:04 AM
|
|
Newcomer
|
|
Join Date: May 2003
Location: Germany
Posts: 9
|
|
Textbox Problem or something like it
|
hi,
this one is going to be a bit longer ...
i wrote this program (source code follows)
i have the two flags TextMode: "Eingabe" and "TempData"
if textmode is "eingabe" then he should write all in the first textbox
if textmode is "tempdata" then he should write all in the second textbox
first i connect (he writes the text in the first textbox) , then i click my button CB_DataModules everything is working fine (he writes the text in the second textbox)
but when i now click CB_DataModules one more time, then he writes the text to the first textbox and not to the second like it is supposed to
can anyone help ?
and please i know that the sourcecode doesnt look good nor is he perfect .. but i am only programming vb for 3 days so please forgive me ;-)
and please tell me where my mistake was and do not only correct it
cya Oliver Schmid (Germany)
so here the source code:
Code:
Private flag As Boolean
Private WaitingFor As String
Private TextMode As String
Private Sub CB_Disconnect_Click()
Call ClosePortIfOpen
End Sub
Private Sub form_load()
Call ClosePortIfOpen
Call setComSettings
Call OpenPort
TextMode = "Eingabe"
End Sub
Private Sub CB_Connect_Click()
flag = False
Call Dial
Call Login
Call setConsoleMode
End Sub
Private Sub CB_DataModules_Click()
Call listDataModules
End Sub
Private Sub CB_Stations_Click()
Call listStations
End Sub
Private Sub CB_Send9_Click()
Call senddata9(T_Eingabe.Text)
End Sub
Private Sub CB_Send10_Click()
Call sendData10(T_Eingabe.Text)
End Sub
Private Sub CB_Send13_Click()
Call sendData13(T_Eingabe.Text)
End Sub
Private Sub listStations()
Call setTMtoTempData
Call sendData10("clist station")
Call sendData10("f8005")
Call sendData10("t")
Call SetWaitingFor("promt")
Call setTMtoEingabe
'Call searchforstations
End Sub
Private Sub listDataModules()
Call setTMtoTempData
Call sendData10("clist data-module")
Call sendData10("f5")
Call sendData10("t")
Call SetWaitingFor("promt")
Call setTMtoEingabe
Call searchForDataModules
MsgBox "fertisch"
End Sub
Private Sub setTMtoEingabe()
T_Text.SelStart = Len(T_Text)
T_Text.SelText = T_TempData.Text
TextMode = "Eingabe"
End Sub
Private Sub setTMtoTempData()
T_TempData.Text = ""
TextMode = "TempData"
End Sub
Private Sub searchforstations()
Dim Search, x
x = 1
Search = Chr(10) & "d"
T_TempData.SelLength = Len(T_TempData.Text)
Do
If InStr(x, T_TempData.Text, Search) Then
x = InStr(x, T_TempData.Text, Search)
T_TempData.SelStart = x + 1
T_TempData.SelLength = 3
Call sendData10("cdisplay station " & T_TempData.SelText)
Call sendData10("t")
Wait (1000)
Else
Exit Sub
End If
x = x + 1
Loop
End Sub
Private Sub searchForDataModules()
Dim Search, x
x = 1
Search = Chr(10) & "d"
T_TempData.SelLength = Len(T_TempData.Text)
Do
If InStr(x, T_TempData.Text, Search) Then
x = InStr(x, T_TempData.Text, Search)
T_TempData.SelStart = x + 1
T_TempData.SelLength = 3
Call sendData10("cdisplay data-module " & T_TempData.SelText)
Call sendData10("t")
Wait (1000)
Else
Exit Sub
End If
x = x + 1
Loop
End Sub
Private Sub Dial()
Call sendData13("ATM1")
Call SetWaitingFor("ATDT302")
Call sendData13("ATDT302")
Call SetWaitingFor("login")
End Sub
Private Sub Login()
Call sendData13("bcmsvu")
Call SetWaitingFor("password")
Call sendData13("bcmsvu1")
Call SetWaitingFor("console")
End Sub
Private Sub setConsoleMode()
Call sendData13("ossis")
Call SetWaitingFor("promt")
End Sub
Private Sub SetWaitingFor(status As String)
WaitingFor = status
Call WaitForFlag
End Sub
Private Sub WaitForFlag()
Do
Wait (10)
Loop Until flag = True
flag = False
End Sub
Private Sub sendData13(buffer As String)
MSComm1.Output = buffer & Chr(13)
End Sub
Private Sub sendData10(buffer As String)
MSComm1.Output = buffer & Chr(10)
End Sub
Private Sub senddata9(buffer As String)
MSComm1.Output = buffer & Chr(9)
End Sub
Private Sub MSComm1_OnComm()
Dim buffer As Variant
Select Case TextMode
Case "Eingabe"
Select Case MSComm1.CommEvent
Case comEvReceive
buffer = StrConv(MSComm1.Input, vbUnicode)
T_Text.SelStart = Len(T_Text)
T_Text.SelText = buffer
Select Case WaitingFor
Case "ATDT302"
If InStr(buffer, "K") Then flag = True
Case "login"
If InStr(buffer, ":") Then flag = True
Case "password"
If InStr(buffer, ":") Then flag = True
Case "console"
If InStr(buffer, "]") Then flag = True
Case "promt"
If InStr(buffer, "t") Then flag = True
Case "data-module"
If InStr(buffer, "t" & Chr(10)) Then flag = True
End Select
End Select
Case "TempData"
Select Case MSComm1.CommEvent
Case comEvReceive
buffer = StrConv(MSComm1.Input, vbUnicode)
T_TempData.SelStart = Len(T_TempData)
T_TempData.SelText = buffer
If InStr(buffer, "t") Then flag = True
End Select
End Select
End Sub
Private Sub setComSettings()
MSComm1.Settings = "9600,n,8,1"
MSComm1.CommPort = 1
MSComm1.InputMode = comInputModeBinary
MSComm1.InputLen = 0
MSComm1.DTREnable = True
MSComm1.EOFEnable = False
MSComm1.RTSEnable = True
MSComm1.NullDiscard = False
MSComm1.ParityReplace = ""
MSComm1.RThreshold = 1
MSComm1.SThreshold = 1
End Sub
Private Sub OpenPort()
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
End Sub
Private Sub ClosePortIfOpen()
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call ClosePortIfOpen
End Sub
|
|

05-08-2003, 08:26 AM
|
|
Regular
|
|
Join Date: May 2003
Location: New York
Posts: 104
|
|
It's kinda difficult to trace that in your code, but my guess is:
Code:
Private Sub listDataModules()
Call setTMtoTempData
Call sendData10("clist data-module" )
Call sendData10("f5" )
Call sendData10("t" )
Call SetWaitingFor("promt" )
Call setTMtoEingabe
Call searchForDataModules
MsgBox "fertisch"
End Sub
|
|

05-08-2003, 08:58 AM
|
|
Freshman
|
|
Join Date: May 2003
Posts: 27
|
|
Quote: Originally Posted by dream hi,
this one is going to be a bit longer ...
i wrote this program (source code follows)
i have the two flags TextMode: "Eingabe" and "TempData"
if textmode is "eingabe" then he should write all in the first textbox
if textmode is "tempdata" then he should write all in the second textbox
first i connect (he writes the text in the first textbox) , then i click my button CB_DataModules everything is working fine (he writes the text in the second textbox)
but when i now click CB_DataModules one more time, then he writes the text to the first textbox and not to the second like it is supposed to
can anyone help ?
and please i know that the sourcecode doesnt look good nor is he perfect .. but i am only programming vb for 3 days so please forgive me ;-)
and please tell me where my mistake was and do not only correct it
cya Oliver Schmid (Germany)
so here the source code:
Code:
Private flag As Boolean
Private WaitingFor As String
Private TextMode As String
Private Sub CB_Disconnect_Click()
Call ClosePortIfOpen
End Sub
Private Sub form_load()
Call ClosePortIfOpen
Call setComSettings
Call OpenPort
TextMode = "Eingabe"
End Sub
Private Sub CB_Connect_Click()
flag = False
Call Dial
Call Login
Call setConsoleMode
End Sub
Private Sub CB_DataModules_Click()
Call listDataModules
End Sub
Private Sub CB_Stations_Click()
Call listStations
End Sub
Private Sub CB_Send9_Click()
Call senddata9(T_Eingabe.Text)
End Sub
Private Sub CB_Send10_Click()
Call sendData10(T_Eingabe.Text)
End Sub
Private Sub CB_Send13_Click()
Call sendData13(T_Eingabe.Text)
End Sub
Private Sub listStations()
Call setTMtoTempData
Call sendData10("clist station")
Call sendData10("f8005")
Call sendData10("t")
Call SetWaitingFor("promt")
Call setTMtoEingabe
'Call searchforstations
End Sub
Private Sub listDataModules()
Call setTMtoTempData
Call sendData10("clist data-module")
Call sendData10("f5")
Call sendData10("t")
Call SetWaitingFor("promt")
Call setTMtoEingabe
Call searchForDataModules
MsgBox "fertisch"
End Sub
Private Sub setTMtoEingabe()
T_Text.SelStart = Len(T_Text)
T_Text.SelText = T_TempData.Text
TextMode = "Eingabe"
End Sub
Private Sub setTMtoTempData()
T_TempData.Text = ""
TextMode = "TempData"
End Sub
Private Sub searchforstations()
Dim Search, x
x = 1
Search = Chr(10) & "d"
T_TempData.SelLength = Len(T_TempData.Text)
Do
If InStr(x, T_TempData.Text, Search) Then
x = InStr(x, T_TempData.Text, Search)
T_TempData.SelStart = x + 1
T_TempData.SelLength = 3
Call sendData10("cdisplay station " & T_TempData.SelText)
Call sendData10("t")
Wait (1000)
Else
Exit Sub
End If
x = x + 1
Loop
End Sub
Private Sub searchForDataModules()
Dim Search, x
x = 1
Search = Chr(10) & "d"
T_TempData.SelLength = Len(T_TempData.Text)
Do
If InStr(x, T_TempData.Text, Search) Then
x = InStr(x, T_TempData.Text, Search)
T_TempData.SelStart = x + 1
T_TempData.SelLength = 3
Call sendData10("cdisplay data-module " & T_TempData.SelText)
Call sendData10("t")
Wait (1000)
Else
Exit Sub
End If
x = x + 1
Loop
End Sub
Private Sub Dial()
Call sendData13("ATM1")
Call SetWaitingFor("ATDT302")
Call sendData13("ATDT302")
Call SetWaitingFor("login")
End Sub
Private Sub Login()
Call sendData13("bcmsvu")
Call SetWaitingFor("password")
Call sendData13("bcmsvu1")
Call SetWaitingFor("console")
End Sub
Private Sub setConsoleMode()
Call sendData13("ossis")
Call SetWaitingFor("promt")
End Sub
Private Sub SetWaitingFor(status As String)
WaitingFor = status
Call WaitForFlag
End Sub
Private Sub WaitForFlag()
Do
Wait (10)
Loop Until flag = True
flag = False
End Sub
Private Sub sendData13(buffer As String)
MSComm1.Output = buffer & Chr(13)
End Sub
Private Sub sendData10(buffer As String)
MSComm1.Output = buffer & Chr(10)
End Sub
Private Sub senddata9(buffer As String)
MSComm1.Output = buffer & Chr(9)
End Sub
Private Sub MSComm1_OnComm()
Dim buffer As Variant
Select Case TextMode
Case "Eingabe"
Select Case MSComm1.CommEvent
Case comEvReceive
buffer = StrConv(MSComm1.Input, vbUnicode)
T_Text.SelStart = Len(T_Text)
T_Text.SelText = buffer
Select Case WaitingFor
Case "ATDT302"
If InStr(buffer, "K") Then flag = True
Case "login"
If InStr(buffer, ":") Then flag = True
Case "password"
If InStr(buffer, ":") Then flag = True
Case "console"
If InStr(buffer, "]") Then flag = True
Case "promt"
If InStr(buffer, "t") Then flag = True
Case "data-module"
If InStr(buffer, "t" & Chr(10)) Then flag = True
End Select
End Select
Case "TempData"
Select Case MSComm1.CommEvent
Case comEvReceive
buffer = StrConv(MSComm1.Input, vbUnicode)
T_TempData.SelStart = Len(T_TempData)
T_TempData.SelText = buffer
If InStr(buffer, "t") Then flag = True
End Select
End Select
End Sub
Private Sub setComSettings()
MSComm1.Settings = "9600,n,8,1"
MSComm1.CommPort = 1
MSComm1.InputMode = comInputModeBinary
MSComm1.InputLen = 0
MSComm1.DTREnable = True
MSComm1.EOFEnable = False
MSComm1.RTSEnable = True
MSComm1.NullDiscard = False
MSComm1.ParityReplace = ""
MSComm1.RThreshold = 1
MSComm1.SThreshold = 1
End Sub
Private Sub OpenPort()
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
End Sub
Private Sub ClosePortIfOpen()
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call ClosePortIfOpen
End Sub
Hallo ich spreche Deine Sprache - logisch ich bin aus Österreich
Sind eine Gruppe von Entwicklern - imspeziellen für EDIFACT
Schick mir das Project an Support@Alusol.at
Wenn Du willst
|
|

05-08-2003, 09:09 AM
|
|
Newcomer
|
|
Join Date: May 2003
Location: Germany
Posts: 9
|
|
Quote: Originally Posted by Akim It's kinda difficult to trace that in your code, but my guess is:
Code:
Private Sub listDataModules()
Call setTMtoTempData
Call sendData10("clist data-module" )
Call sendData10("f5" )
Call sendData10("t" )
Call SetWaitingFor("promt" )
Call setTMtoEingabe
Call searchForDataModules
MsgBox "fertisch"
End Sub
yeah okay ... but what is wrong with it ? i dont see what should be wrong with that ?
|
|

05-08-2003, 09:54 AM
|
|
Regular
|
|
Join Date: May 2003
Location: New York
Posts: 104
|
|
|
[/QUOTEPOST]
yeah okay ... but what is wrong with it ? i dont see what should be wrong with that ?[/QUOTEPOST]
Sorry Dream, nothing is wrong with it, but there are to many calls in your code.
Try to run your code with breakpoints to trace the problem.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|