|
-
Jun 22nd, 2006, 03:36 AM
#1
Thread Starter
Junior Member
[2005] Hi ppl - Open dir [RESOLVED]
hi all...
i have a form With:
Button1
listbox1
listbox2
wath i need is wen i click my button open the thir:
("C:\Programs\ "+ listbox1.Selecteditem) ---- this work fine
but if i need
("C:\Programs\" + listbox1.selecteditem + listbox2.selecteditem )
supose i have a selected item in listbox1 -- EXP and i have other in listbox2 -- TEXT.txt, wen i click button1 i need this result:
open ("c:\Programs\EXP\TEXT.txt)
Last edited by Bruno Frade; Jun 22nd, 2006 at 04:01 AM.
-
Jun 22nd, 2006, 03:39 AM
#2
Re: [2005] Hi ppl - Open dir
You simply need to concatenate with an additional "\" between the two list box items. Alternatively you could use the String.Format method, or even IO.Path.Combine twice.
-
Jun 22nd, 2006, 03:43 AM
#3
Fanatic Member
Re: [2005] Hi ppl - Open dir
Something like this....
("C:\Programs\" & listbox1.selecteditem & "\" & listbox2.selecteditem)
Bob
"I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings
-
Jun 22nd, 2006, 03:46 AM
#4
Thread Starter
Junior Member
Re: [2005] Hi ppl - Open dir
tks for all, but can you explain in a few words the diference between
("C:\Programs\" + listbox1.selecteditem)
and
("C:\Programs\" & listbox1.selecteditem)
just to learn...
txk bie
Bruno Frade
-
Jun 22nd, 2006, 03:49 AM
#5
Fanatic Member
Re: [2005] Hi ppl - Open dir
+ is a math operator, used for addition.
& is a text operator.
I think, but I'm sure JMC will be more concise.... very shortly....
"I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings
-
Jun 22nd, 2006, 03:54 AM
#6
Re: [2005] Hi ppl - Open dir
"+" is the addition operator while "&" is the concatenation operator.
"str1" + "str2" = "str1str2"
"str1" & "str2" = "str1str2"
1 + 2 = 3 -> The number 3
1 & 2 = "12" -> A string
"str1" + 2 -> Unhandled Exception: Cannot convert String to Integer
"str1" & 2 = "str12"
-
Jun 22nd, 2006, 03:59 AM
#7
Thread Starter
Junior Member
Re: [2005] Hi ppl - Open dir [RESOLVED]
ok, tkx very much
congratz to VBForums, and for all members..
-
Jun 22nd, 2006, 04:00 AM
#8
Re: [2005] Hi ppl - Open dir
And...
"10" + 2 = 12 -> The number 12
Basically, "+" will concatenate if both operands are strings but otherwise will try to convert to Double if the operands are different types. If the string can be converted to a Double then it is, otherwise an excpetion is thrown. "&" will convert both operands to type String by calling their ToString method no matter what the type of either operand.
-
Jun 22nd, 2006, 04:04 AM
#9
Fanatic Member
Re: [2005] Hi ppl - Open dir
^^^ Told ya !
 Originally Posted by staticbob
I think, but I'm sure JMC will be more concise.... very shortly....
"I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|