|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Mid(string) function
Hi, I am trying to use this function. But the string is a variable, I dont know the length. How to solve this problem. Thanks in advance!!!
|
|
#2
|
||||
|
||||
|
So many possible answers, all depending on what specifically you are trying to do.
Can you post some sample input/output cases.
__________________
-
thought-after | my thoughts on web development Get Firefox, the developers browser Budget hosting - recommended [/left] |
|
#3
|
|||
|
|||
|
The data string I receive it through serial com, eg, T30H54L12, then I want to seprate it and pass the value to 3 variable, eg, a=30, b=54, c=12. But the length may not be the same, eg, T224H0L128, the output should be a=224, b=0, c=128, thank you so much!
|
|
#4
|
|||
|
|||
|
get the length by len(string)
use a loop and the mid statement to then decipher the text |
|
#5
|
|||
|
|||
|
Sorry, I still can not figure it out, if I write the code as following, what should be the x, y, z? Because I dont know how long is the data, eg, T45H234L0, but somtimes it is T0H4L9. I hope you understand my question.By the way, what loop are you refering to? Thank you so much!!
string = MSComm1.Input n=len(string) tmp = Mid(string, 2, x) hum = Mid(string, x+3, y) light = Mid(string, x+3+y, z) |
|
#6
|
|||
|
|||
|
Dim XString AsString
Dim I, N, M AsInteger Dim tmp, hum, light AsInteger XString = MSComm.Input N = Len(XString) M = 0 For I = 1 To N If Mid(XString, I, 1) = "H" Then tmp = Mid(XString, 2, I - 2) M = I + 1 EndIf If Mid(XString, I, 1) = "L" Then hum = Mid(XString, M, I - M) light = Mid(XString, I + 1, N - I) EndIf Next I MsgBox(tmp) MsgBox(hum) MsgBox(light) |
|
#7
|
|||
|
|||
|
Thanks a lot!
![]() |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Mid(string) function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|