|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
String commands
Could someone help me with the command to convert a string into a number, and also if i had a string of say " 29387" if I only wanted 387 is that rtrim, or another command, its been so long
|
|
#2
|
|||
|
|||
|
depends on the type of number you want. try CInt or CLng.
for the second part you could try Right$(" 29387", 3) |
|
#3
|
|||
|
|||
|
thanks
|
|
#4
|
|||
|
|||
|
You can use the Val command to convert a string to a number:
Val("1234") + 5 'would = 1239 If you want to convert to a specific numeric type, use the conversion functions like; CInt, CDec, CLng etc. CInt("12345.6") '=12346 the fraction is rounded up on converting to an int. |
|
#5
|
|||
|
|||
|
oh thanks, thats the command i was looking for, lol i was trying value(textbox.text)
|
|
#6
|
|||
|
|||
|
what about formulas in strings?
Well, what would be a solution when you considering formulas in string. Suppose I have a string "1*2" and need the solution as an integer.. can it be done?
thanks pete |
|
#8
|
||||
|
||||
|
took a while, but here is the site for download - add the component to your project, and then you can just do something like this
Code:
Private Sub Form_Load() Dim strFunction As String Dim result As Variant strFunction = "1+6*15" result = ScriptControl1.Eval(strFunction) MsgBox result End Sub ...it really does display 91! |
|
#9
|
|||
|
|||
|
Good lord! It works!! And to think I racked my brains ripping the expression apart and assigned variables to each number and moved forth! Why, with one component its done! THANKS FISHERMAN!
![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > String commands |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|