Results 1 to 9 of 9

Thread: string variables

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2004
    Location
    Middle of nowhere
    Posts
    45

    string variables

    Hey, i was wondering, is there a way i could store a variable in mid-string?

    like rather then saying
    VB Code:
    1. Dim strName As string
    2.  
    3. strName = txtinput.text
    have it do something like

    VB Code:
    1. If txtinput.text = "my name is <Variable>"(then have it store whatever you put in that slot as strName) then
    2. messagebox.show: "you said your name was " & strName
    3. End If

    if you understand this question and have a solution, would appricate it

    thanks
    --Flac
    Everything great once started with the words "That will never catch on, you shouldnt even bother" be great, go against the crowed, do something stupid, you might become famous.

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    Re: string variables

    Originally posted by Flac

    if you understand this question and have a solution, would appricate it

    thanks
    --Flac
    Messagebox.Show ("you said your name was " & txtboxinput.text)

  3. #3
    Addicted Member Hole-In-One's Avatar
    Join Date
    Mar 2003
    Location
    Minnesota
    Posts
    195
    No, that'll give you a message box that says

    "you said your name was my name is Tim"

    I think what he wants is a messagebox that says

    "you said your name was Tim"

    I think this code will give you that:

    Code:
     strName = txtInput.Text
    
            Dim lastspace As Integer = strName.LastIndexOf(" ")
            Dim name As String = strName.Substring(lastspace)
    
            MsgBox("you said your name was " & name)

  4. #4
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    what if they type "since you asked, frank is my name."

  5. #5
    Addicted Member Hole-In-One's Avatar
    Join Date
    Mar 2003
    Location
    Minnesota
    Posts
    195


    No kidding! How do you control what they enter in the box?

  6. #6
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I think he's probably best of inheriting from System.Net.AI.SuperArtificalIntelligence.Genius class...

    Then using the Genius.FigureOutMyName method.

  7. #7
    Addicted Member Hole-In-One's Avatar
    Join Date
    Mar 2003
    Location
    Minnesota
    Posts
    195
    That class must be in the next release of VS

    I'll have to upgrade

  8. #8
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Oh yea Whidby rocks....

    There's also the System.Security.SuperUltraSecure.Impenetrable class....

    My personal favorite though is System.Life.LiveForever class, which has the public method MakeImmortal. I'm gonna LOVE that one!

  9. #9

    Thread Starter
    Member
    Join Date
    Mar 2004
    Location
    Middle of nowhere
    Posts
    45
    Heh, yes your right "how do i control what they type"

    But see the example i gave isnt what im applying it to, the actaul program im putting it in has little room for anything but what the command would be.

    its just that the actaul program is more complex then the bit of code i need, so i figured to get the code it would be easier to just give a name finder as an example

    as for the next version of VS, sounds good count me in

    maybe it will come with a
    system.WriteMyCodeForMe.MakeItWork.RightFreakennow
    method...that would be grand...

    but ya, thanks for the assist, i will try to earlier mentioned code and see if i can piece it together


    ---Flac
    Everything great once started with the words "That will never catch on, you shouldnt even bother" be great, go against the crowed, do something stupid, you might become famous.

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