VS 2008 Autoselect int group in text box-VBForums
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
    129

    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
    129

    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
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Autoselect int group in text box

    So is your problem resolved...not resolved...somewhere in between?
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.