Sending String To TextBox

mach278

Newcomer
Joined
Jun 9, 2003
Messages
4
Hey guys, I was hoping you could help me with the algorithm/code for what I want to do. Basically, I’m building an interface that will communicate with a microcontroller through the serial port. I already have serial communication working and can send and receive strings. However, I’m not sure how to do the following. Basically, let’s say the interface has two text boxes, TextBox A and TextBox B. Here’s my question: the microcontroller will be sending strings, such as “A=100” telling the program to put the value 100 in TextBox A and “B=105” to put 105 in TextBox B. Can anyone offer any tips on how to program the VB project to do this, send the string to its appropriate TextBox? Any help will be greatly appreciated. Thanks!
 
My suggestion. You can create a hashtable and populate it w/ your controls that should receive notification:

Private m_Controls As New Hashtable()
'-In Form.Load, initialize your hash table; key is name of textbox.

m_Controls.Add(TextBox1.Name, TextBox1)
m_Controls.Add(TextBox2.Name, TextBox2)

'-in event where you have to send message.
Dim strCtrlName, strMessage As String
'-Extract control name and message; code left out...

CType(m_Controls(strCtrlName), TextBox).Text = strMessage
 
Back
Top