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:
  #1  
Old August 30th, 2005, 03:31 PM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 739 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 9 h 12 m 28 sec
Reputation Power: 22
Write to Variable

I have some code that is reading a string from the CommPort. I have that string writing to a variable. The string is comma delimeted so I have code in place to break it apart by the commas. I then write it to a counter and spit back all the sections of the string.

What I want to do is write each section to a variable...anyone have any thoughts? See Code example below.....I would have to replace the "For iCounter" statement with code to place each section into variables. I dont know the syntax I should use....


I AM IN ACCESS VBA.....

THanks

NMEAString is a global variable that is storing the string pushed to the CommPort......


CODE:

Dim s As String, sItems() As String
Dim iCounter As Integer
Dim NMEA As String

NMEA = NMEAString
sItems = Split(NMEA, ",") 'This splits by a comma. Change if needed","

For iCounter = LBound(sItems) To UBound(sItems)
MsgBox sItems(iCounter)
Next

Reply With Quote
  #2  
Old August 31st, 2005, 12:35 AM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
You could always do something like
[code]
var1 = sitems(0)
var2 = sitems(1)
' etc
[code]
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #3  
Old August 31st, 2005, 12:47 AM
Guddu's Avatar
Guddu Guddu is offline
Contributing User
Click here for more information.
 
Join Date: Jul 2005
Location: Oxford UK
Posts: 3,652 Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level)Guddu User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 2 Days 13 h 10 m 43 sec
Reputation Power: 787
what result ur getting........pls post

Reply With Quote
  #4  
Old August 31st, 2005, 09:36 AM
Jaykappy Jaykappy is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Feb 2005
Posts: 739 Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level)Jaykappy User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 9 h 12 m 28 sec
Reputation Power: 22
Write to Variable

Question is there a way I can place my code in this forum without it placing it all on the left margin....
the code looks very sloppy and makes it hard to read....there are comments after most lines so ignore them.....if there was a way I could retain the format it would be far easier to read.

I actually hacked away at this last night and got it working....this is what I coded....I thank you all for your help...I am really developing my skills with all of your help...I hope to repay the favor with helping others someday on this site.....

Note For anyone looking at this....I will be posting my entire code for pulling the NMEA String from a Trimble Unit and bringing it into Access. In its raw for there are a couple buttons...

Retrieve Button - Gets the string adn displays it in a text box

Get String Button - grabs teh same string, splits it by comma, parses the string and write each wated section to seperate variables that can be grabbed by any portion of the form.

I THANK YOU ALL FOR YOUR HELP......


CODE FOR SPLITTING AND SETTING STRING SECTIONS TO VARIABLES:

Public Sub GetString_Click()

Dim s As String, sItems() As String
Dim i As Integer
Dim NMEA As String

NMEA = NMEAString 'Sets the Variable from MSComm6 to NMEA
sItems = Split(NMEA, ",") 'This splits by a comma. Change if needed","

i = 0
For i = 0 To UBound(sItems) 'Sets i to the Upper Bound of sItems or the NMEA String
NewCoords = Trim(sItems(i)) 'Trims the spaces on either side of the string
If i = 2 Then 'Looks for teh 6th word in the string
X = NewCoords 'Sets the 6th word to the variable First1
ElseIf i = 3 Then
LongHem = NewCoords
ElseIf i = 4 Then
Y = NewCoords
ElseIf i = 5 Then
LatHem = NewCoords
ElseIf i = 9 Then
Elev = NewCoords
ElseIf i = 10 Then
ElevUnit = NewCoords

End If
Next 'Walks through the string

MsgBox X 'Returns the variables in a message box
MsgBox LongHem
MsgBox Y
MsgBox LatHem
MsgBox Elev
MsgBox ElevUnit


End Sub

Reply With Quote
  #5  
Old September 1st, 2005, 02:51 AM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
Quote:
Question is there a way I can place my code in this forum without it placing it all on the left margin....

Look at the forum FAQ's. There is a section on "forum codes" like [ code ] [ /code ] (without the spaces in the brackets btw) There are many other handy forum codes you can use in your posts.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Write to Variable


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 5 hosted by Hostway
Stay green...Green IT