Jump to content
Xtreme .Net Talk

Should I use a LOOKUP, a REGEX or what? How would you do it?


Recommended Posts

Posted

Gentlemen:

 

Could you let me know what strategy would you use for doing the following?

 

The Example Data shown below is being gathered from a Machine through the RS232 port into a RichTextBox1 in VB.NET

 

Once the Data is in the RichTextBox1 we need to parse it into Textboxes, which are labeled accordingly for the User to examine the collected data.

 

Once the Data is examined, the user clicks the SAVE button and the data is inserted into the Datagrid1 below on the same mainform1, thereby creating a new record entry in the Database.

 

Here is the explanation of The Example Data below; lets take line 8 as an example;

 

CA3*450*325*225*0*775*650*350*425

 

Each Asterisk separates a field name; there are 8 fields in this line.

 

Value 450 is field CA301

Value 325 is field CA302

Value 225 is field CA303

Value 0 is field CA304�. You get the idea?

 

QUESTION:

What technique would you use to parse these values into their corresponding Textboxes? Assuming that the name of the textboxes will be the name of the fields, example;

 

Textbox1 name = CA301

Textbox2 name = CA302

Textbox3 name = CA303�. You get the idea?

 

On a Separate Database we have the all the element definition for these fields.

CA301 Value of Cash In Since Last Reset

CA302 Value of Cash To Cash Box Since Last Reset

CA303 Value of Cash to Tubes Since Last Reset

CA304 Value of Bills In Since Last Reset

CA305 Value of Cash In Since Initialization

CA306 Value of Cash To Cash Box Since Initialization

CA307 Value of Cash To Tubes Since Initialization

CA308 Value of Bills In Since Initialization

 

 

Example Data

 

DXS*9259630004*VA*V1/1*1**

ST*001*0001

ID1*ªªªªªªªªªªªªªªªªªªªªªª*Merlinazary 4 67100-7 *701***

ID4*2*1*

ID5*990302*0634

VA1*0*0*0*0

VA2*0*0*0*0

CA3*450*325*225*0*775*650*350*425

CA4*0*0*0*0

CA7*0*0

DA2*0*0*0*0

TA2*0*0*0*0

LS*0100

PA1*1*50*

PA2*0*0*0*0

PA1*2*50*

PA2*0*0*0*0

PA1*3*50*

PA2*0*0*0*0

PA1*4*50*

PA2*0*0*0*0

PA1*5*50*

PA2*0*0*0*0

PA1*6*50*

PA2*0*0*0*0

PA1*7*50*

PA2*0*0*0*0

PA1*8*50*

PA2*0*0*0*0

PA1*9*50*

PA2*0*0*0*0

PA1*10*50*

PA2*0*0*0*0

LE*0100

EA2*CR**0

EA2*DO*2

EA3*0

EA7*9*9

MA5*BAUD*9600

MA5*SWITCH*UNLOCK*1,2*50*7,8,10

MA5*TUBE1**0

MA5*TUBE2*

MA5*SEL1*1,7

MA5*SEL2*2,8

MA5*SEL3*3

MA5*SEL4*4

MA5*SEL5*5

MA5*SEL6*6

MA5*SEL7*9

MA5*SEL8*10

MA5*SEL9*11

MA5*SEL10*12

MA5*SEL11*

MA5*SEL12*

SD1*000000000000

G85*75EC

SE*56*0001

DXE*1*1

  • Leaders
Posted

not sure if this helps :

   Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
       Dim str() As String = "CA3*450*325*225*0*775*650*350*425".Split("*")
       Dim fakeTextBox() As String = DirectCast(str, Array)
       Dim i As Integer, x As Integer, tb As Control
       For i = 1 To 8
           x = i - 1
           For Each tb In Me.Controls
               If TypeOf tb Is TextBox Then
                   If tb.Name = "TextBox" & i Then
                       tb.Text = fakeTextBox(x)
                   End If
               End If
           Next
       Next
   End Sub

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...