How to get value from text box (string)

I have following string in textbox now I want to fetch some of the data and put into another textbox.

Within this string -
"<TH class=displaytable_attribute scope=col>GC No.</TH>"
i want only GC No. in label1 and its value from  this line  is 15470038084 in text box 1
"<TD style="COLOR: #000000" class=displaytable_value><A style="BACKGROUND-COLOR: yellow">15470038084</A></TD>"
and same for the rest of the value like
for GC Date in label3 and its value in text box 3
<TH class=displaytable_attribute scope=col>GC Date</TH>
and value  is
<TD class=displaytable_value>23/10/2017</TD>

 and so on for the rest of the fields........

hope you understand what i want

plz assist me how to do that

thanks in advance

Data I have in the following format

<TD class=style1><BR><BR>&nbsp;<A href="Index.aspx"><IMG style="HEIGHT: 41px" src="images1/1ee.jpg"></A></TD>
<TD><BR><BR>&nbsp;&nbsp;&nbsp; </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<TABLE border=0 cellSpacing=0 cellPadding=0 width="100%">
<TD style="WIDTH: 750px; HEIGHT: 100px">&nbsp;<BR><A class=Heading_TrackingDetails name=tracking>Tracking Details </A><BR><BR>
<TABLE cellSpacing=0 width="100%">
<TD class=cellborder_none colSpan=6 border="0"><B>Booking Details</B></TD></TR>
<TH class=displaytable_attribute scope=col>GC No.</TH>
<TH class=displaytable_attribute scope=col>GC Date</TH>
<TH class=displaytable_attribute scope=col>GC Time</TH>
<TH class=displaytable_attribute scope=col>From</TH>
<TH class=displaytable_attribute scope=col>To</TH>
<TH class=displaytable_attribute scope=col>Consignor</TH>
<TH class=displaytable_attribute scope=col>Consignee</TH>
<TH class=displaytable_attribute scope=col>Qty</TH>
<TH class=displaytable_attribute scope=col>Weight</TH>
<TH class=displaytable_attribute scope=col>Inv_No</TH></TR>
<TD style="COLOR: #000000" class=displaytable_value><A style="BACKGROUND-COLOR: yellow">15470038084</A></TD>
<TD class=displaytable_value>23/10/2017</TD>
<TD class=displaytable_value>12:00:00 AM </TD>
<TD class=displaytable_value>VARANASI</TD>
<TD class=displaytable_value>SHOLAPUR</TD>
<TD class=displaytable_value>MUSKAN SAREE</TD>
<TD class=displaytable_value>CHATLA SAREE</TD>
<TD class=displaytable_value>3</TD>
<TD class=displaytable_value>90</TD>
<TD class=displaytable_value>X</TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 width="100%">
Who is Participating?
Martin LissOlder than dirtCommented:
I assume that the data comes from a txt file. I've attached the text file that I used and a project that processes it. To test it you will need to save the file to some folder and then change the Open "C:\temp\29067879.txt" For Input As #FF line in the code.
Pawan KumarDatabase ExpertCommented:
What language are u using?
crystal_TechAuthor Commented:
thanks for reply Pawan

i am using vb6.0
David Johnson, CD, MVPOwnerCommented:
normally I'd use in the code behind

var abc = textbox1.text
textbox2.txt = abc
Hopefully this code is near to what you need.
Option Explicit

Private Sub Command1_Click()
    Dim lStart As Long
    Dim strElement As String
    Dim i As Integer
    Dim strValue As String
    Dim Labels(10) As String
    Dim Values(10) As String
    lStart = 1
    'Get table header text
    For i = 1 To 10
        lStart = GetNextElement(Form1.Text1.Text, lStart, "TH", strElement, strValue)
        If lStart = 0 Then
            Exit Sub
        End If
        Labels(i) = strValue
        lStart = lStart + Len(strElement)
    Next i
    'get table call text
    For i = 1 To 10
        lStart = GetNextElement(Form1.Text1.Text, lStart, "TD", strElement, strValue)
        If lStart = 0 Then
            Exit For
        End If
        Values(i) = strValue
        lStart = lStart + Len(strElement)
    Next i
    'transfer text from arrays to text box
    For i = 1 To 10
        Form1.Text2.Text = Form1.Text2.Text & Labels(i) & ": " & Values(i) & vbCrLf
    Next i
End Sub

Function GetNextElement(strHTML As String, lCurrentPosition As Long, strTag As String, strElement As String, strValue As String) As Long
    Dim lStart As Long
    Dim lEnd As Long
    lStart = InStr(lCurrentPosition, strHTML, "<" & strTag & " ", vbTextCompare)
    If lStart > 0 Then
        lEnd = InStr(lStart, strHTML, "</" & strTag & ">", vbTextCompare)
        If lEnd > 0 Then
            strElement = Mid(strHTML, lStart, lEnd - lStart + 5)
            GetNextElement = lStart
        End If
        strValue = GetValue(strElement, strTag)
    End If
End Function

Function GetValue(strElement As String, strTag As String) As String
    Dim lAttrEnd As Long
    lAttrEnd = InStr(1, strElement, ">", vbTextCompare) + 1
    GetValue = Mid(strElement, lAttrEnd, Len(strElement) - lAttrEnd - Len("</" & strTag))
End Function

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.