I've just started learning VB. I can't get how to declare string variables in VB. I need some help.
Tell me about declaring string variables.
Page 1 of 112 Replies - 652 Views - Last Post: 01 July 2009 - 02:07 PM
Replies To: Tell me about declaring string variables.
#2
Re: Tell me about declaring string variables.
Posted 01 July 2009 - 01:15 PM
It's rather simple
What exactly were your looking for?
Dim SomeVariable As String
What exactly were your looking for?
#3
Re: Tell me about declaring string variables.
Posted 01 July 2009 - 01:18 PM
Being able to do both either a string variable or a numeric veriable.
#4
Re: Tell me about declaring string variables.
Posted 01 July 2009 - 01:20 PM
Declaring an integer variable is the same as a string variable
Dim SomeVariable As String Dim AnotherVariable As Integer
#5
Re: Tell me about declaring string variables.
Posted 01 July 2009 - 01:25 PM
Awesome. Thank you.
#6
Re: Tell me about declaring string variables.
Posted 01 July 2009 - 01:34 PM
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.
'problem1.vbs' Dim aString As String = "Hello" Dim bString as String = "World" ' Displays "HelloWorld." ' MsgBox(aString & bString)
#7
Re: Tell me about declaring string variables.
Posted 01 July 2009 - 01:36 PM
Declaring a variable and setting it are two different tasks. Try this
Dim aString As String Dim bString as String Set aString = "Hellp" Set bString = "World" ' Displays "HelloWorld." ' MsgBox(aString & bString)
#8
Re: Tell me about declaring string variables.
Posted 01 July 2009 - 01:39 PM
Still giving me the same error.
Says the problem is on line 3, character 13 with an expected end of statement.
'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: 01 July 2009 - 01:45 PM
#9
Re: Tell me about declaring string variables.
Posted 01 July 2009 - 01:44 PM
My bad, by default all VBScript variables are of type Variant, and can hold any kind of data type. Try this:
Dim aString, bString aString = "Hellp" bString = "World" ' Displays "HelloWorld." ' MsgBox(aString & bString)
#10
Re: Tell me about declaring string variables.
Posted 01 July 2009 - 01:46 PM
#11
Re: Tell me about declaring string variables.
Posted 01 July 2009 - 01:57 PM
Glad I could help 
Now go forth and become a Variable Declaring Guru
Now go forth and become a Variable Declaring Guru
#12
Re: Tell me about declaring string variables.
Posted 01 July 2009 - 02:06 PM
I'm also attempting to append a string to another string. Here's my code. It keeps giving me errors.
Dim aString, bString, cString aString = "Hellp" bString = "World" cString = aString//bString ' Displays "HelloWorld." ' MsgBox(cString)
#13
Re: Tell me about declaring string variables.
Posted 01 July 2009 - 02:07 PM
Not sure why you have a // in between the two variables but do this
Also, when mentioning that you're getting errors let us know what the error message if that you're receiving
cString = aString & bString
Also, when mentioning that you're getting errors let us know what the error message if that you're receiving
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|