SunQuest
 
           Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
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  
Old November 3rd, 2004, 09:06 PM
pingping pingping is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Singapore
Posts: 9 pingping User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via MSN to pingping
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!!!

Reply With Quote
  #2  
Old November 3rd, 2004, 09:33 PM
Lafinboy's Avatar
Lafinboy Lafinboy is offline
The Laughing Moderator
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Apr 2004
Location: Sydney, Australia
Posts: 3,263 Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)  Folding Points: 29199 Folding Title: Starter FolderFolding Points: 29199 Folding Title: Starter Folder
Time spent in forums: 2 Weeks 1 Day 10 h 35 m 51 sec
Reputation Power: 15
Send a message via ICQ to Lafinboy Send a message via AIM to Lafinboy Send a message via MSN to Lafinboy Send a message via Yahoo to Lafinboy Send a message via Skype to Lafinboy
So many possible answers, all depending on what specifically you are trying to do.

Can you post some sample input/output cases.

Reply With Quote
  #3  
Old November 3rd, 2004, 11:14 PM
pingping pingping is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Singapore
Posts: 9 pingping User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via MSN to pingping
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!

Reply With Quote
  #4  
Old November 3rd, 2004, 11:30 PM
SoberButCrazy SoberButCrazy is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 15 SoberButCrazy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
get the length by len(string)

use a loop and the mid statement to then decipher the text

Reply With Quote
  #5  
Old November 3rd, 2004, 11:57 PM
pingping pingping is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Singapore
Posts: 9 pingping User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via MSN to pingping
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)

Reply With Quote
  #6  
Old November 4th, 2004, 12:18 AM
SoberButCrazy SoberButCrazy is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 15 SoberButCrazy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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)


Reply With Quote
  #7  
Old November 4th, 2004, 01:15 AM
pingping pingping is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Singapore
Posts: 9 pingping User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via MSN to pingping
Thanks a lot!

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Mid(string) function


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway