Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Textbox Problem or something like it


Reply
 
Thread Tools Display Modes
  #1  
Old 05-08-2003, 09:04 AM
dream dream is offline
Newcomer
 
Join Date: May 2003
Location: Germany
Posts: 9
Default 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
Reply With Quote
  #2  
Old 05-08-2003, 09:26 AM
Akim Akim is offline
Regular
 
Join Date: May 2003
Location: New York
Posts: 104
Default

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
Reply With Quote
  #3  
Old 05-08-2003, 09:58 AM
SamiLagusto SamiLagusto is offline
Freshman
 
Join Date: May 2003
Posts: 27
Default

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
Reply With Quote
  #4  
Old 05-08-2003, 10:09 AM
dream dream is offline
Newcomer
 
Join Date: May 2003
Location: Germany
Posts: 9
Default

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 ?
Reply With Quote
  #5  
Old 05-08-2003, 10:54 AM
Akim Akim is offline
Regular
 
Join Date: May 2003
Location: New York
Posts: 104
Default

[/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.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
textbox visable problem Cityking General 2 04-17-2003 09:44 AM
need help with textbox validation problem tomreid Word, PowerPoint, Outlook, and Other Office Products 0 03-05-2003 09:37 AM
problem with textbox (input) luchmun General 5 02-17-2003 11:30 AM
Display the process step in Textbox problem andrewchoi General 2 02-13-2003 02:42 AM
TextBox Event problem!! mms General 3 08-18-2002 10:31 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->