i am working on an application where some test results are received
from a serial port and getting stored line by line in a text box.now
i have to compare each line with an existing data base( that is with a field of each record )and display interpretation of each line stored in other field of the record.
first how to select a line from a text box.
Can anybody help me

i don't understand....what is line?

Hi,

In textBox(Multi Line =True), if you have stored Line by line , then split the text with Line seperator:

Dim MyArr
MyArr = Split (Text1.Text, vbCrLF)

and loop through MyArr

Change the line seperator(vbCrLF), accrdingly..

Regards
Veena

Thanka veena,
i did not really got you.
is there any command just to pick up a line from a text box

Hi,

Can you post 4-5 lines of what is stored in the textbox...?

REgards
Veena

The data viewed in a text box is given below :-
DSOT.
/
OT SIM NOP
***ONP FLT SWC
***001000000000000010000000
***ET 00001 SECONDS AT ONP FLT
ET 00001 SECONDS
"#$%&'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_?
TTW , END
TWS3 END
SEARCH ANTENNA NOT OPERABLE
TWS2 END
SEARCH ANTENNA NOT OPERABLE

thanks for the code.Now i am able to pick out a line from the
text box. Now to form a loop in order to compare with a data base,
i have to know the number of lines in a text box. is there any command
to find out number of lines in a text box.

Hi
As per veena in the previous post,
you can split the text by using Split() function
ie

Dim MyArr 
MyArr = Split (Text1.Text, vbCrLF)

Now MyArr is an array with each element representing a line

You can get a line by using Index of the Array. For example MyArr(0) represents the first line The upper bound + 1 is the number of lines
Ex

Dim iNumOfLines as integer
iNumOfLines = UBound(MyArr) + 1

Thanks Ganapathy
the code is working fine, could u please look at the codes
codes:
' assign each line to an Array:
'COMPARE EACH LINE WITH A DATA BASE

TextLines() = Split(Text1.Text & vbCrLf, vbCrLf)
inumberOfLines = UBound(TextLines())
For Length = 0 To inumberOfLines

For NUMBER = 1 To 5
Data1.RecordSource = "SELECT * FROM faultmsg WHERE ID=" & NUMBER
Data1.Refresh
If TextLines(Length) = Data1.Recordset.Fields("FAULT MSG") Then
Text6.Text = Data1.Recordset.Fields("FAULT INTERPRETATION")
Else
End If
Next

Next

Can you help me if two lines of the text box matches two records of the database,
then then the next match should be displayed in the next line of text6.text.
i mean one line matches displays a interpretation in text6.text, and when another line matches the interpretation should display in the next line of text6.text.

Again Error 'OBJECT DOES NOT SUPPORT THIS PROPERTY OR METHOD,
IS DISPLAYED. I have to click OK for the loop to continue.

Hi apuamy,
Is the code and ur questions

if two lines of the text box matches two records of the database,
then then the next match should be displayed in the next line of text6.text.
i mean one line matches displays a interpretation in text6.text, and when another line matches the interpretation should display in the next line of text6.text.

are related? can u specify where (In which line of your code) the error occured?

Is This coding fetches Fault Interpretation for Fault Msg?

Hello Ganapathy,
i am working on a fault diagnostic package for a equipment.
i send a command from my computer to an equipment through a serial port and
receive some error message from the equipment in text1.text. Now the error message
of that equipment is received in mnemonics. Now i compare the received message in text1.text with a database and display a result in text6.text.Fault interpretation and fault message
is fields of my data base and the datas are related to the faults of the equipment i am testing.

while executing the visual codes i am getting the error message
"'OBJECT DOES NOT SUPPORT THIS PROPERTY OR METHOD,
IS DISPLAYED"
i have put the codes in a command button, whenever i click the command button the codes are executed and starts comparing with a data base from already received data in text1.text.

HELLO GANAPATHY and Veena
my line by problem is solved thanks for all the help.
But my only problem remains is the error shows by the VB program
" OBJECT DOESNT SUPPORT THIS PROPERTY OR METHOD ".
The codes r working perfectly ok but VB is showing this error.
Can u help me.

Hello apuamy,
did u solve the database fetching problem? Please tell where this error "Object Does not support the property or method" (From which line u getting this error). It may be use of property or method that the object dont have.
Try to run the Program using Ctrl + F5
If any compiler error it will stop the compilation. Please specify the line where compilation stop.

Thanks Ganapathy,
my problem of error is solved.
that was because i had connected three data base with the form which was un used.
can u tell me how to strip a string character by character.
i am getting data 11000110011110001111. I want to store 1 or o in a array and then compare with a data base for its interpretation.
the code split is not working as there is no separator between ones and zeroes.
can u help me

Hi apuamy,

To split 1's and 0's use Mid(), Left() or Right() function.

Dim Binary() as String
Dim Length as Integer
Dim sBin as String
Dim i as Integer 

sBin = "100101110"
Length = Len(sBin)
Redim Binary (Length - 1) As String

For i= 0 to Length -1
   Binary (i) = Mid ( sBin, i + 1, 1)
Next

Now Binary () Array Contains the Separated Binary values

Thanks again Ganapathy,
My problem is solved. Now i can get binary data in array and compare with a database
and interpret.
The code which you have written is used in following way
codes-
------------------------------------------------------------------------------------------
Dim Length As Integer
Length = Len(Text1)
ReDim Binary(Length - 1) As String

For i = 0 To Length - 1
Binary(i) = Mid(Text1, i + 1, 1)

Next
'Now Binary () Array Contains the Separated Binary value
For NUMBER = 1 To 4

Data1.RecordSource = "SELECT * FROM SPT_RESULTS WHERE ID=" & (NUMBER)
Data1.Refresh
ser = NUMBER - 1
If Binary(ser) = Data1.Recordset.Fields("SPT Result") Then
Text2.Text = Text2.Text + Data1.Recordset.Fields("Fault Interpretation")
Text2 = Text2 & vbCrLf
Else

End If

Next

If Text2.Text = "" Then
MsgBox "There is no SPT Fault in The System"
Else
End If
------------------------------------------------------------------------------------------
Now what code i have to attach in red colour lines to see output in text2.text after comparing with the data as
FAULT NUMBER 1 : value from the database field "fault Interpretation"
FAULT NUMBER 2 :
-
-
-
thanks once again ganapathy .

Hi apuamy,

I think u are seem to be in right direction. I dont know how can i help u.

thanks Ganapathy
my problem is solved.

hello ganapathy,
i am haning a little problem in comparing string.
data which comes from a serial port is given below
---------------------
***BRN FLT
***0011
***010
TAR , SIN END
018.6 METERS
--------------------------
now i am storing the lines in a one dimensional array using command
TextLines() = Split(Text1.Text & vbCrLf, vbCrLf)
now when i start comparing with a data base ***BRN FLT cannot be compares as
the lines has three spaces.
My problem now is once the data comes in a text box line by line, i have to delete the
spaces before putting in a array and then compare.

if the line ***BRN FLT has spaces after the data it cannect be compared with a data base
having text ***BRN FLT as it does not have blank spaces after the text.
My codes for splitting line in a array and then comparing is given below
-----------------
Dim COUNT As Integer
COUNT = 1
Text2.Text = ""
Length = 0

' assign each line to an Array:

TextLines() = Split(Text1.Text & vbCrLf, vbCrLf)
inumberOfLines = UBound(TextLines())

'COMPARE EACH LINE WITH A DATA BASE

For Length = 0 To inumberOfLines

For NUMBER = 1 To 24

Data1.RecordSource = "SELECT * FROM faultmsg WHERE ID=" & NUMBER
Data1.Refresh
If TextLines(Length) = Data1.Recordset.Fields("FAULT MSG") Then
Text2.Text = Text2.Text + "FAULT NUMBER" & " " & COUNT & ": " & Data1.Recordset.Fields("FAULT INTERPRETATION")
Text2 = Text2 & vbCrLf
Text2 = Text2 & vbCrLf

COUNT = COUNT + 1
Else
End If

Next

Next
If Text2.Text = "" Then
MsgBox "There is no Fault in The System"
Else
End If
------------------------
can u help me

Hi,

I guess, you can Trim and Check..

If Trim(TextLines(Length)) = Trim(Data1.Recordset.Fields("FAULT MSG") ) Then

Regards
Veena

Thanks Veena,
your code worked straightaway.
thanks for the help
apuamy

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.