|
-
Feb 8th, 2010, 12:14 PM
#1
Thread Starter
New Member
[Newbie Question] Loop Problem
I am developing a GUI for a device called LabJack to get streaming data of UV light intensity.
Code:
For i = 0 To numScansToDisplay - 1
For j = 1 To numChannel
testdata = Format(adblData(j - 1 + (numChannel * i)), "#.####") + ","
data = data + testdata
Next j
data = CStr(TimeValue(Now)) + data + vbCrLf
Next i
RichTextBox1.Text = RichTextBox1.Text + data
This is the result i get
4:31:41 PM4:31:41 PM4:31:41 PM4:31:41 PM-.0005,4.9894,-.3128,-.3178,
-.0005,4.9843,-.3758,-.3909,
-.0005,4.9843,-.411,-.4211,
-.0005,4.9843,-.401,-.4236,
4:31:42 PM4:31:42 PM4:31:42 PM4:31:42 PM.002,4.9843,-.3959,-.4262,
-.0005,4.9818,-.4236,-.4362,
-.0005,4.9818,-.3959,-.4262,
.002,4.9793,-.4236,-.4312,
But if i change the code to
Code:
data = data + CStr(TimeValue(Now)) + vbCrLf
The results are
-.0005,4.9894,-.3128,-.3178,4:31:41 PM
-.0005,4.9843,-.3758,-.3909,4:31:41 PM
-.0005,4.9843,-.411,-.4211,4:31:41 PM
-.0005,4.9843,-.401,-.4236,4:31:41 PM
In fact, what i am trying to get is:
4:31:41 PM,.002,4.9843,-.3959,-.4262,
4:31:41 PM,-.0005,4.9818,-.4236,-.4362,
4:31:41 PM,-.0005,4.9818,-.3959,-.4262,
4:31:41 PM,.002,4.9793,-.4236,-.4312,
I have tried numeours codes but i have no idea how to do it 
Thanks for help
-
Feb 8th, 2010, 12:20 PM
#2
Re: [Newbie Question] Loop Problem
With strings: Use & to combine them, not +
If using math on strings, ensure you convert the string to appropriate variable type first, i.e., CDbl(theString), CLng(theString), etc. Failing to do this could result in type mismatch errors and/or potentially incorrect calculations.
-
Feb 8th, 2010, 12:24 PM
#3
Re: [Newbie Question] Loop Problem
Try:
data = CStr(TimeValue(Now)) & "," & data & "," & vbCrLf
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Feb 8th, 2010, 12:25 PM
#4
Re: [Newbie Question] Loop Problem
 Originally Posted by some1uk03
Try:
data = CStr(TimeValue(Now)) & "," & data & "," & vbCrLf
But that isn't the only line that is using + to concatenate strings. OP should review post #2 also.
-
Feb 9th, 2010, 02:52 AM
#5
Thread Starter
New Member
Re: [Newbie Question] Loop Problem
Thanks LaVolpe and Some1uk30.
I have tried your suggestions, but it doesn't work also.
-
Feb 9th, 2010, 05:34 AM
#6
Re: [Newbie Question] Loop Problem
Since I cannot test your code, Try this and tell me what are the two exact messages that you are getting?
Code:
For i = 0 To numScansToDisplay - 1
For j = 1 To numChannel
testdata = Format(adblData(j - 1 + (numChannel * i)), "#.####") + ","
Data = Data & testdata
Next j
MsgBox "1~~> " & Data '<~~ 1st Message
Data = CStr(TimeValue(Now)) & Data & vbCrLf
MsgBox "2~~> " & Data '<~~ 2nd Message
Exit Sub '<~~ For testing purpose only
Next i
Last edited by Siddharth Rout; Feb 9th, 2010 at 05:37 AM.
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Feb 9th, 2010, 09:10 AM
#7
Re: [Newbie Question] Loop Problem
 Originally Posted by syahzuan
Thanks LaVolpe and Some1uk30.
I have tried your suggestions, but it doesn't work also. 
Maybe you should show us your modified code and also tell us how you declared Data & testData.
Last edited by LaVolpe; Feb 9th, 2010 at 09:31 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|