What's Here?
Members: 300,424
Replies: 826,035
Topics: 137,457
Snippets: 4,419
Tutorials: 1,148
Total Online: 1,506
Members: 83
Guests: 1,423
Loading. Please Wait...
Tell me about declaring string variables.
Tell me about declaring string variables.
PsychoCoder
RE: Tell Me About Declaring String Variables. 1 Jul, 2009 - 12:15 PM
Dyslexics Untie!
Joined: 26 Jul, 2007
Posts: 14,714
Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery
My Contributions
It's rather simple
CODE
Dim SomeVariable As String
What exactly were your looking for?
ILoveSushi
RE: Tell Me About Declaring String Variables. 1 Jul, 2009 - 12:18 PM
New D.I.C Head
Joined: 1 Jul, 2009
Posts: 13
Being able to do both either a string variable or a numeric veriable.
PsychoCoder
RE: Tell Me About Declaring String Variables. 1 Jul, 2009 - 12:20 PM
Dyslexics Untie!
Joined: 26 Jul, 2007
Posts: 14,714
Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery
My Contributions
Declaring an integer variable is the same as a string variable
CODE
Dim SomeVariable As String Dim AnotherVariable As Integer
ILoveSushi
RE: Tell Me About Declaring String Variables. 1 Jul, 2009 - 12:25 PM
New D.I.C Head
Joined: 1 Jul, 2009
Posts: 13
Awesome. Thank you.
ILoveSushi
RE: Tell Me About Declaring String Variables. 1 Jul, 2009 - 12:34 PM
New D.I.C Head
Joined: 1 Jul, 2009
Posts: 13
Everytime I try to run this, it gives me an error on line 3, char 13 with an error message: Expected end of statement. I'm using Notepad.
CODE
'problem1.vbs' Dim aString As String = "Hello" Dim bString as String = "World" ' Displays "HelloWorld." ' MsgBox(aString & bString)
PsychoCoder
RE: Tell Me About Declaring String Variables. 1 Jul, 2009 - 12:36 PM
Dyslexics Untie!
Joined: 26 Jul, 2007
Posts: 14,714
Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery
My Contributions
Declaring a variable and setting it are two different tasks. Try this
CODE
Dim aString As String Dim bString as String Set aString = "Hellp" Set bString = "World" ' Displays "HelloWorld." ' MsgBox(aString & bString)
ILoveSushi
RE: Tell Me About Declaring String Variables. 1 Jul, 2009 - 12:39 PM
New D.I.C Head
Joined: 1 Jul, 2009
Posts: 13
Still giving me the same error.
CODE
'problem1.vbs' Dim aString As String Dim bString As String Set aString = "Hello" Set bString = "World" ' Displays "HelloWorld." ' MsgBox(aString & bString)
Says the problem is on line 3, character 13 with an expected end of statement.
This post has been edited by ILoveSushi : 1 Jul, 2009 - 12:45 PM
PsychoCoder
RE: Tell Me About Declaring String Variables. 1 Jul, 2009 - 12:44 PM
Dyslexics Untie!
Joined: 26 Jul, 2007
Posts: 14,714
Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery
My Contributions
My bad, by default all VBScript variables are of type Variant, and can hold any kind of data type. Try this:
CODE
Dim aString, bString aString = "Hellp" bString = "World" ' Displays "HelloWorld." ' MsgBox(aString & bString)
ILoveSushi
RE: Tell Me About Declaring String Variables. 1 Jul, 2009 - 12:46 PM
New D.I.C Head
Joined: 1 Jul, 2009
Posts: 13
QUOTE(PsychoCoder @ 1 Jul, 2009 - 12:44 PM)
My bad, by default all VBScript variables are of type Variant, and can hold any kind of data type. Try this:
CODE
Dim aString, bString aString = "Hellp" bString = "World" ' Displays "HelloWorld." ' MsgBox(aString & bString)
Awesome. Now it works.
PsychoCoder
RE: Tell Me About Declaring String Variables. 1 Jul, 2009 - 12:57 PM
Dyslexics Untie!
Joined: 26 Jul, 2007
Posts: 14,714
Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery
My Contributions
Glad I could help
Now go forth and become a Variable Declaring Guru
ILoveSushi
RE: Tell Me About Declaring String Variables. 1 Jul, 2009 - 01:06 PM
New D.I.C Head
Joined: 1 Jul, 2009
Posts: 13
I'm also attempting to append a string to another string. Here's my code. It keeps giving me errors.
CODE
Dim aString, bString, cString aString = "Hellp" bString = "World" cString = aString//bString ' Displays "HelloWorld." ' MsgBox(cString)
PsychoCoder
RE: Tell Me About Declaring String Variables. 1 Jul, 2009 - 01:07 PM
Dyslexics Untie!
Joined: 26 Jul, 2007
Posts: 14,714
Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery
My Contributions
Not sure why you have a
// in between the two variables but do this
CODE
cString = aString & bString
Also, when mentioning that you're getting errors let us know what the error message if that you're receiving