Results 1 to 4 of 4

Thread: Autoselect int group in text box

  1. #1

    Thread Starter
    Addicted Member condonethis's Avatar
    Join Date
    Apr 2010
    Location
    TX
    Posts
    133

    Question 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:
    1. Public Sub removal()
    2.         Dim obxnum As String = 1
    3.         Dim text As String = TxtMsg.Text
    4.         'Almost always by 100 it removes everything,
    5.         'if there is a better method please advise
    6.         Do Until obxnum = 100
    7.             text = Replace(text, "OBX|" + obxnum + "|TX|^" + TxtOBXState.Text + ".Report Text", "")
    8.             obxnum = obxnum + 1
    9.             'write back
    10.      
    11.   Loop
    12.  
    13.         text = Replace(text, "||", "")
    14.         TxtMsg.Text = text
    15. 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

  2. #2
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Re: Autoselect int group in text box

    I'd suggest looking at Regex.Replace for this.

    http://www.knowdotnet.com/articles/r...ntstrings.html
    This world is not my home. I'm just passing through.

  3. #3

    Thread Starter
    Addicted Member condonethis's Avatar
    Join Date
    Apr 2010
    Location
    TX
    Posts
    133

    Talking Re: Autoselect int group in text box

    Quote Originally Posted by trisuglow View Post
    I'd suggest looking at Regex.Replace for this.

    http://www.knowdotnet.com/articles/r...ntstrings.html
    Thank you!

    VB.NET Code:
    1. Dim myMatch As Match = System.Text.RegularExpressions.Regex.Match(TxtMsg.Text, "\b\d{5}.\b\d{4}")
    2.  
    3.         If Not myMatch.Success Then
    4.             Dim newmatch As Match = System.Text.RegularExpressions.Regex.Match(TxtMsg.Text, "\b\d{6}.\b\d{4}")
    5.             TxtOBXState.Text = newmatch.ToString
    6.         Else
    7.  
    8.             'First Name was incorrect
    9.             TxtOBXState.Text = myMatch.ToString
    10.             Return
    11.  
    12.         End If

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Autoselect int group in text box

    So is your problem resolved...not resolved...somewhere in between?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width