Results 1 to 5 of 5

Thread: Quotes to Variable

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Posts
    482
    Hey, how would i put ANYTHING
    between 2 "'s into a variable

    like:

    "Nobody Knows"

    then Variable(1) = Nobody Knows

    but it could be anyamount of words, 1 or 15, it doesn't matter

    THANKS

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Use
    Code:
    MsgBox """Hello"""
    OR
    MsgBox Chr(34) & "Hello" & Chr(34)
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Posts
    482
    i guess i didn't explain it enough..

    i mean like, i have a textbox, and if someone types something like
    "yo" i said, and he said "what up"

    var(1) = yo
    var(2) = what up

    ..
    so what ever is INBETWEEN 2 "'s would go into a variable..

    and i could have many variables..



    Thanks

  4. #4
    Guest
    Can you explain yourself just a bit more? What do you mean so what ever is INBETWEEN 2 "'s would go into a variable.. ?

    Do you mean spaces? You could use the split function, put it into arrays.

    Code:
    Private Sub Command1_Click()
       
        Dim vArray As Variant
        Dim strArray As String
        Dim iArray As Integer
    
        vArray = Split(Text1.Text, " ")
        For i = 0 To UBound(vArray)
            strArray = strArray & vArray(iArray) & vbCrLf
        Next i
        MsgBox strArray 
    
    End Sub
    ^should get you started.
    Chr(34) = " 'quote

  5. #5
    Hyperactive Member marnitzg's Avatar
    Join Date
    Oct 2000
    Location
    South Africa
    Posts
    372

    Talking

    I think this is what you want!

    I put them into a dynamic array.
    Code:
    Private Sub Command1_Click()
    Dim I As Integer, ArrLen As Integer
    Dim Vars() As String
    
    ArrLen = -1
    For I = 1 To Len(Text1.Text)
        If Mid(Text1.Text, I, 1) = Chr(34) Then
            ArrLen = ArrLen + 1
            ReDim Preserve Vars(ArrLen)
            Vars(ArrLen) = Mid(Text1.Text, I + 1, InStr(I + 1, Text1.Text, Chr(34)) - I - 1)
            I = InStr(I + 1, Text1.Text, Chr(34)) + 1
        End If
    Next
    End Sub
    For instance the sentance : "I am testing" to see "if" this "works" will end up like this:
    Vars(0) = I am testing
    Vars(1) = if
    Vars(2) = works
    Is that what you want? Or am I as confused as the rest of them?

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