Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
split a variable
#1
Solved: 10 Years, 9 Months, 1 Week ago
Hey guys,

I have a variable that is getting passed to me in the form of -
VarA = $2000.
My problem is when i start to try and use this variable as an Integer....such as when i try and add my variable to another integer -
VarA + 300 = VarB

Here i get a "type mismatch" error. (due to the $ sign in front of the 2000)

My question would be does anybody know how i can strip the $ sign away so that im left with just the Integer?

Thanks,
Brian
Reply
#2
Solved: 10 Years, 9 Months, 1 Week ago
convert that to an int using cint. for ex.
MyDouble = "$2000"
MyInt = CInt(MyDouble)
Msgbox (MyInt) will do the trick.
Reply
#3
Solved: 10 Years, 9 Months, 1 Week ago
Try using Split function.
Example:
Code:
Dim StrMsg, MyArray
StrMsg = "$2000"
MyArray = Split(StrMsg, "$", -1, 1)
' now
' MyArray(0) contains ""
' MyArray(1) will contain 2000

Msgbox MyArray(1)
Reply
#4
Solved: 10 Years, 9 Months, 1 Week ago
You can also use this,
d = "$1000"
msgbox Right(d, (Len(d)-1))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Split function in string nidhishnair 13 63,372 07-07-2020, 03:47 PM
Last Post: helmzshelmz
Question Split Function Chaithra N 0 1,015 12-18-2019, 11:33 AM
Last Post: Chaithra N
  Split a string with multiple delimiters in VBScript nandha 2 7,963 02-10-2018, 06:44 PM
Last Post: nandha
  Split Function diya 2 5,557 11-28-2012, 08:49 PM
Last Post: diya
Question Deatils on Split action with Nested type sams001 0 3,190 10-30-2012, 03:03 PM
Last Post: sams001

Forum Jump:


Users browsing this thread: 1 Guest(s)