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]
 
Put it as an attachment on your next post. Go down the screen a bit and you'll see a button that says manage attachments. You can upload it in there.
 
Ok, has a play with it, but as i said this is all from memory. I'm off to lunch now but i'll be back to help out ( or not as the case may be ) in about an hour or so.
 

Attachments

  • TryThisOne.zip
    28.3 KB · Views: 21
LOL. After i corrected the spelling and removed the module.'s from the Form1 form it worked like a charm. thanks chief! By the way I noticed you're from the UK. have you seen Shaun of the Dead or Ali G in da house? I don't ususally like English or British movies but those are 2 of my favorites. Are people from the UK British or English? (Enlgish accent) Me loves 'he way yous guys tolk an oll 'at.
 
Ok I copied the code from the generator and the double ' doesn't work. When i copied it to my myspace account it recognized ' ' instead of ". As a result the downward scroll and other stuff is ignored.
 
TextBox1.Text = "<marquee Behaviour=" + chr(34) + "scroll" + chr(34) + "direction= " + chr(34) "down" + chr(34) + " "

I posted this a bit earlier on, you must have missed it. Also here's a link to a site that has a bit of code that copies the contents of a textbox to the clipboard.

http://www.devcity.net/Articles/89/1/spellcheck.aspx
 
Last edited:
chr(34) is that " ? Where can i find out the other character #'s just out of curiosity? That could come in handy.
 
maybe i'm just retarded but I can't get it to work and it's bedtime. Here's what I have so far.
 

Attachments

  • MatrixHTMLgenerator.zip
    31.5 KB · Views: 14
It's much easier to use two double quotes when you need to quote something inside a quoted string. Chr(43) makes a lot of confusing &.
Also using String.Format may simplify string parameters.
Also using a System.Text.StringBuilder could be of help when building strings.
Three examples you should examine: (the 'str' variable is a string variable)
1. Substituted the quotes:
VB.NET:
str = "<marquee behavior=""scroll"" direction=""down"" scrollamount=""" & scrollAmount.ToString & """ style=""position:absolute; left:" & LeftPosi.ToString & "; top:" & TopPosi.Tostring & "; width:14; height:900; z-index:1300; color:green;"">" & Symbols & "</marquee>" & vbTab
2. Using String.Format with parameters:
VB.NET:
str = String.Format("<marquee behavior=""scroll"" direction=""down"" scrollamount=""{0}"" style=""position:absolute; left:{1}; top:{2}; width:14; height:900; z-index:1300; color:green;"">{3}</marquee>" & vbNewLine, _
                    scrollAmount.Tostring, LeftPosi.Tostring, TopPosi.Tostring, Symbols)
3. Using StringBuilder:
VB.NET:
Dim sb As New System.Text.StringBuilder
sb.Append("<marquee ")
sb.Append("behavior=""scroll"" ")
sb.Append("direction=""down"" ")
sb.Append(String.Format("scrollamount=""{0}"" ", scrollAmount.Tostring))
sb.Append(String.Format("style=""position:absolute; left:{0}; top:{1}; width:14; height:900; z-index:1300; color:green;"" ", LeftPosi.Tostring, TopPosi.Tostring))
sb.Append(">")
sb.Append(Symbols)
sb.Append("</marquee>" & vbNewLine)
MsgBox(sb.ToString)
 
Ok, i've has a further play with it, and it will now do what you want it to do. I used one of JohnH's examples in the project, because it was a better idea than mine.:)
 

Attachments

  • MatrixHTMLgenerator.zip
    34.7 KB · Views: 16
I love this place. You better watch out we might have to bump up your reputation. Thanks for all the help.
 
i'm finished with the Matrix HTML generator if anyone wants to take a look at it or point out what i did wrong, which I'm sure is something.
 
Back
Top