Join two value into one variable 
Author Message
 Join two value into one variable

Is there a way to join two string values into one variable similar to what
happens in javascript? I have a strArg variable which is a number 1-12. I
want to do the following:

projNumber = "Project" + strArg

Is there a way to do this in VBScript?

Thanks for the help,

David Brown



Fri, 11 Jul 2003 00:47:42 GMT  
 Join two value into one variable
If its a string value then you will need to convert it

MyStr = "12"    'This is the string variable
MyStrToInt = CInt(MyStr)

'Now your other value is lets say 10
OtherVal = 10

'To Add them together you would

result = MyStrToInt + OtherVal

MsgBox result


Quote:
> Is there a way to join two string values into one variable similar to what
> happens in javascript? I have a strArg variable which is a number 1-12. I
> want to do the following:

> projNumber = "Project" + strArg

> Is there a way to do this in vbscript?

> Thanks for the help,

> David Brown



Fri, 11 Jul 2003 01:30:34 GMT  
 Join two value into one variable
On Sun, 21 Jan 2001 16:47:42 GMT impersonator of "Jason Hadrava"

microsoft.public.scripting.vbscript:

Quote:
>Is there a way to join two string values into one variable similar to what
>happens in javascript? I have a strArg variable which is a number 1-12. I
>want to do the following:

>projNumber = "Project" + strArg

>Is there a way to do this in vbscript?

The same - "+", or (better) - "&"

Quote:
>Thanks for the help,

>David Brown

LeoNid


Fri, 11 Jul 2003 01:23:23 GMT  
 Join two value into one variable
On Sun, 21 Jan 2001 17:23:23 GMT impersonator of "~~~i LeoNid~~"

microsoft.public.scripting.vbscript:

Quote:
>On Sun, 21 Jan 2001 16:47:42 GMT impersonator of "Jason Hadrava"

>microsoft.public.scripting.vbscript:

>>Is there a way to join two string values into one variable similar to what
>>happens in javascript? I have a strArg variable which is a number 1-12. I
>>want to do the following:

>>projNumber = "Project" + strArg

>>Is there a way to do this in vbscript?

>The same - "+", or (better) - "&"

Oops. Missed the point that this was about NUMBER. (as explained in
another response here:-( Sorry. Leonid.


Fri, 11 Jul 2003 04:13:21 GMT  
 Join two value into one variable
projNumber = "Project" & strArg

The proper way to concatenate strings is with the & operator.  In some cases + will work and in some
cases it will fail, in particular when one of the operands is a number and it becomes ambiguous as
to whether concatenation or addition was intended.  With & it's never ambiguous - even numbers will
be coerced to strings and concatenated.

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:

> Is there a way to join two string values into one variable similar to what
> happens in javascript? I have a strArg variable which is a number 1-12. I
> want to do the following:

> projNumber = "Project" + strArg

> Is there a way to do this in vbscript?

> Thanks for the help,

> David Brown



Fri, 11 Jul 2003 08:23:36 GMT  
 Join two value into one variable
If strArg is a Number(i.e.strArg=5)  then:

 projNumber = "Project" + Cstr(strArg)


Quote:
> Is there a way to join two string values into one variable similar to what
> happens in javascript? I have a strArg variable which is a number 1-12. I
> want to do the following:

> projNumber = "Project" + strArg

> Is there a way to do this in vbscript?

> Thanks for the help,

> David Brown



Mon, 14 Jul 2003 03:04:09 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Help : Breaking One WORD variable to two BYTE variable in VB

2. joining two files as one

3. Join two recordsets into one using DAO 3.6?

4. help i need to join two or more tables to one

5. Two joins in one sql statement?

6. Joining two tables from two databases

7. Here's a sticky wicket - joining two tables on two diffrent servers with ADO

8. Concatenate two fields to one usable variable

9. UserForm - insert two values from one listbox

10. How to get two return values from one fuction

11. combo box with two values displaying one at a time

12. Linking two tables to enable inserting value from one to other

 

 
Powered by phpBB® Forum Software