Autoselect int group in text box
I have a richtextbox that I paste a HL7 msg into and then harvest the message instance manually from the text, what I would like to do is automate the harvest of this integer to automate the selection process.
example of message:
OBX|1|TX|^13971.8498.Report Text||Examination: Right elbow series
OBX|2|TX|^13971.8498.Report Text
OBX|3|TX|^13971.8498.Report Text||Examination date: February 18, 2011
OBX|4|TX|^13971.8498.Report Text
.......................................
I have the code to remove all the OBX segments after selecting and the msg number 13971.8498 and pasting it into a textbox. This leaves me with a nice report that can be read by the general public.
vb.net Code:
Public Sub removal()
Dim obxnum As String = 1
Dim text As String = TxtMsg.Text
'Almost always by 100 it removes everything,
'if there is a better method please advise
Do Until obxnum = 100
text = Replace(text, "OBX|" + obxnum + "|TX|^" + TxtOBXState.Text + ".Report Text", "")
obxnum = obxnum + 1
'write back
Loop
text = Replace(text, "||", "")
TxtMsg.Text = text
End Sub
I would prefer that there be no textbox involved and that upon button click auto select the integer instance and dim it as my string variable within my script to remove the OBX segments.
I know txtbox.Select(10,?)
Now how can I solve for ? being as this number is incremental and will change in string length?
Thanks,
Chad
Re: Autoselect int group in text box
Re: Autoselect int group in text box
Quote:
Originally Posted by
trisuglow
Thank you!
VB.NET Code:
Dim myMatch As Match = System.Text.RegularExpressions.Regex.Match(TxtMsg.Text, "\b\d{5}.\b\d{4}")
If Not myMatch.Success Then
Dim newmatch As Match = System.Text.RegularExpressions.Regex.Match(TxtMsg.Text, "\b\d{6}.\b\d{4}")
TxtOBXState.Text = newmatch.ToString
Else
'First Name was incorrect
TxtOBXState.Text = myMatch.ToString
Return
End If
Re: Autoselect int group in text box
So is your problem resolved...not resolved...somewhere in between?