How to simulate a LCD display in VB.NET ?

  • Thread starter Thread starter David
  • Start date Start date
D

David

Hi,

I want to simulate a 20 character x 4 line LCD display in VB.NET (2003).

Previously I tried a text box then a listview and finally a datagrid.
The datagrid I thought would have been the best control to use but I
could not figure out how to write to the cells individually.

The expectation is to be able to write to any cell in the control like
LCD(3,1) = "A"

Any help appreciated

Thanks

Regards

David
 
David said:
Hi,

I want to simulate a 20 character x 4 line LCD display in VB.NET (2003).

Previously I tried a text box then a listview and finally a datagrid.
The datagrid I thought would have been the best control to use but I
could not figure out how to write to the cells individually.

The expectation is to be able to write to any cell in the control like
LCD(3,1) = "A"

Any help appreciated

Thanks

Regards

David

You could use 4 textboxes. You can then use the TextBox.Chars(X) = "A"c.

If you want to handle each cell in a datagrid individually you have to
do it through the datasource. for instance if you use a datatable,
change the cells in the table and the datagrid will change.

Chris
 
Chris,

Chars does not seem to be a member of textbox. I can only see a chars
member under textbox.text.chars but this is read only.

Can you explain how I write to the character location?

Thanks

Regards

David
 
David said:
Chris,

Chars does not seem to be a member of textbox. I can only see a chars
member under textbox.text.chars but this is read only.

Can you explain how I write to the character location?

Thanks

Regards

David


Ah, well sorry, I was doing it from memory.

You could use SelectLength/SelectText or do it through substring:

TextBox.SelectionStart = 4
TextBox.SelectionLength = 1
TextBox.SelectionText = "A"c

That would replace the 4th character (maybe the 5th) in the textbox.

Hope that helps.
Chris
 
David said:
Chris,

Chars does not seem to be a member of textbox. I can only see a chars
member under textbox.text.chars but this is read only.

Can you explain how I write to the character location?

Thanks

Regards

David

You could also create one textbox with the multiline property set to true,
then access the Lines array (e.g., MyTextBox.Lines(1) would give you the
second line of text). You can then use the various string manipulation
functions to insert and retrieve characters at specific locations within
each line.

The following is from the Visual Studio 2003 MSDN Library:

Public Sub ViewMyTextBoxContents()
Dim counter as Integer
'Create a string array and store the contents of the Lines property.
Dim tempArray() as String
tempArray = textBox1.Lines

'Loop through the array and send the contents of the array to debug
window.
For counter = 0 to tempArray.GetUpperBound(0)
System.Diagnostics.Debug.WriteLine( tempArray(counter) )
Next
End Sub


Dave
 
Back
Top