strings

skaryChinezeGuie

Well-known member
Joined
Apr 23, 2006
Messages
94
Programming Experience
Beginner
I am making an HTML code generator and need to display text in a textbox that has quotations but when i tried it errored out.

VB.NET:
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Button1_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] Button1.Click
TextBox1.Text = "<marquee behavior="[B][COLOR=red][U]scroll" direction="down" "[/U][/COLOR][/B]
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE]
 
I think you have to use the old double, double quotes here......Just open your string with double quotes as normal, then put two single quotes next to each other.

" ''Hello!!, i'm a string in a string'' "
 
No, it's not... I've heard you can do it this way....

TextBox1.Text = "<marquee behavior=""scroll"" direction=""down"" "

Or It may also br possible this way...

TextBox1.Text = "<marquee Behaviour=" + chr(34) + "scroll" + chr(34) + "direction= " + chr(34) "down" + chr(34) + " "
 
my bad. but you can help me with something else.

VB.NET:
[SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Button1_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] Button1.Click
Scroll()
LeftPos()
TopPos()
TextBox1.Text = "<marquee behavior=''scroll'' direction=''down'' scrollamount=" & "''" & scrollAmount & "'' " & "style=''position:absolute; left:" & LeftPosi & "; " & "top:" & TopPosi & "; " & "width:14; height:900; z-index:1300; color:green;''>" & Symbols & "</marquee>" & vbTab
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE]

this displays the HTML code correctly now but I need it to display the same string several times but each time the ScrollAmount, LeftPosi, and TopPosi variables need to be different. I already set it up so that when you push the button the 3 variables are assigned random numbers. I was thinking about using a "Do until" statement but i'm not sure how to go about it.
 
VB.NET:
[SIZE=2][COLOR=#0000ff]Do
[/COLOR][/SIZE][SIZE=2]Counter()
TextBox1.Text = "<marquee behavior=''scroll'' direction=''down'' scrollamount=" & "''" & scrollAmount & "'' " & "style=''position:absolute; left:" & LeftPosi & "; " & "top:" & TopPosi & "; " & "width:14; height:900; z-index:1300; color:green;''>" & Symbols & "</marquee>" & vbTab
[/SIZE][SIZE=2][COLOR=#0000ff]Loop[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Until[/COLOR][/SIZE][SIZE=2] nCount = 10
[/SIZE]

this works but overwrites the previous strings. I need it to add to the textbox instead of replace.
 
The textbox.text is a string array. The TextBox has a lines property which is
the object of the textbox.text. If you change your Do loop for a For/Next loop.
You should be able to get the desired result..

VB.NET:
Dim StrArray(9) As String
 
For I as integer = 0 to 9
StrArray(i) = "<marquee behavior=''scroll'' direction=''down'' scrollamount=" 
& "''" & scrollAmount & "'' " & "style=''position:absolute; left:" & LeftPosi & "; " & "top:" & TopPosi & "; " & 
"width:14; height:900; z-index:1300; color:green;''>" & Symbols & "</marquee>" & vbTab
Next
Textbox.Lines = StrArray
 
VB.NET:
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] RadioButton1.Checked [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] I [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] 10
Counter1()
TextBox1.Lines(I) = "<marquee behavior=''scroll'' direction=''down'' scrollamount=" & "''" & scrollAmount & "'' " & "style=''position:absolute; left:" & LeftPosi & "; " & "top:" & TopPosi & "; " & "width:14; height:900; z-index:1300; color:green;''>" & Symbols & "</marquee>" & vbTab
[/SIZE][SIZE=2][COLOR=#0000ff]Next
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE]

did i I do that right? it said Index was outside the bounds of the array when it got to the Textbox1.lines(I). I've been up for 3 days minus 2 one-hour naps. without drugs.
 
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] strarray(10) [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] RadioButton1.Checked [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] I [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] 10
Counter1()
Scroll()
LeftPos()
TopPos()
strarray(I) = "<marquee behavior=''scroll'' direction=''down'' scrollamount=" & "''" & scrollAmount & "'' " & "style=''position:absolute; left:" & LeftPosi & "; " & "top:" & TopPosi & "; " & "width:14; height:900; z-index:1300; color:green;''>" & Symbols & "</marquee>" & vbTab
[/SIZE][SIZE=2][COLOR=#0000ff]Next
[/COLOR][/SIZE][SIZE=2]TextBox1.Lines = strarray
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE]

I stepped through the program and watched the numbers change but I noticed it does not go to the last line "TextBox1.Lines = strarray" which
I assume is the line that posts the text in the textbox. all the lines have the same numbers. Any ideas? Oh and thanks for the help so far.
 
Bummer, sounded ok in my head. I'm not at my development pc so i didn't have a chance to check it. So your saying that the last line doesn't get executed? Strange. Also what do you mean by all the lines have the same numbers?
 
It looked good to me too! by numbers i mean the scrollamount, left and top numbers. I moved the last line above the "next" and now I get weird results. a few lines are the same and then the next few are the same but with different numbers. I'd like to either post a zip file here or send it to u to look at. I can't really explain it any clearer.
 
Yea, do that, post the .zip file and i'll check it out. But leave out the Bin, and debug folders. Are you saying that you are not getting anything at all in the texbox? I take it you have set it's multiline property to true?:)
 
no there's stuff there, it's just not what i was expecting. I wanted the scrollamount, left and top numbers to be different in every line. Where should i send it to?
 
Back
Top