i'm very - very newbie here, i need a help, i try to connect arduino with vb6, i want to display data from arduino to vb6, lets say the data is : "the distance : XX m", the problem is when i want to put data via mscomm.input to temp, the value of temp isn't equal with mscomm.input (the script is : temp = mscomm.input), i know this when i try to debugging, like in this pic...why is this happen and...any solution, please?
like i wrote in post before, when i try to run (F5) there's an error 13, data missmatch, then i'm trying to debug, the error occurs on the " jarak = Mid(strFilter(I), 6, 3) ", when i move my mouse over ".Input" the data was similar with the data from arduino, but when i move to "strInput", the data isn't complete...
this is my code :
Select Case .CommEvent
strInput = .Input
temp = temp + strInput
Text1.Text = Text1.Text & temp
Text1.SelStart = Len(Text1.Text)
jarak = Mid((Text1.Text), 6, 3)
strHsl = Split((Text1.Text), vbCrLf)
For I = 0 To UBound(strHsl)
hsl = strHsl(I)
strFilter = Filter(strHsl, "cm", True, vbTextCompare)
For I = 0 To UBound(strFilter)
angka = Now & " - " & strFilter(I) & vbCrLf
jarak = Mid(strFilter(I), 6, 3)
txtView = txtView & angka
nilai.Caption = ((jarak / 13) * 100)
ProgressBar1.Value = ((jarak / 13) * 100)
actually, i just want to take the number from arduino's data trough serial port, arduino sent like this : "Tinggi : xx cm", it sends every 0,5 second, my code just like this :
strInput = .Input
when i debug and move my cursor the data in strInput doesn't same with .Input, so, for the next code it cause error like i said, .Input contain data "Tinggi : xx cm Tinggi : xx cm Tinggi : xx cm... ", but strInputonly contain "Ting", not completely, any suggestion please?
@AndreRet : i declared "jarak" as integer, .Input and strInput as string, is it true? i don't know exactly, i'm very very noob here, i think it caused by mismatch given-received data in strInput = .Input (please see my pic in 1st post), may be you have suggestion for me then...
@tinstaafl : i've tried your suggestion, but still not working, strInput = strInput & .Input, strInput has different contain data with strInput & .Input, just like before.
@AndreRet : i've just tried your suggestion, remove the "Dim jarak As Integer" and just do "Dim jarak", and my unlucky may be, it still don't work.
for the mid function, i'm sure it's correct, it just little bit modified in arduino data that want to sent to vb, if you've seen the pict, the data in the code strInput = .Input is different,
.Input ---> "Tinggi : xx cm Tinggi : xx cm Tinggi : xx cm..." strInput---> "Ting"
I think I caught your problem. If I look at your photo, you are setting mid correctly to return from 6. You do however ask to read 3 spaces and not 2 to cover for the 14 of 14 cm. When returning 3 spaces, it returns 14 AND an empty space which will result in an empty data returned value, hence the error. change the 3 to 2 and let me know if that solved the error.
@AndreRet and @tinstaafl : i have a little bit enlightment, i remove Text1.SelStart = Len(Text1.Text) and jarak = Mid((Text1.Text), 6, 3) in row 8 and 9.
if i follow your suggestion to change in the mid function, replace the length, how if i want to take data if the data in hundred, lets say the data is 1-150, it cause a badly reading right? may be both of you have a good methode to read data correctly...
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11| 12| 13| 14|
| T | i | n | g | g | i | | : | | x | x | | c | m |
, then you could try this,jarak = Val(Mid(Text1.Text,10,3)). The Val function is a little more forgiving in that it will ignore leading and trailing spaces(i.e. it will process 2 or 3 digit numbers without a problem). Also if it can't parse a number from the string it will return 0 instead of throwing an exception.
@AndreRet and @tinstaafl :sorry for long time to tell you the result and thanx for reply.... :)
i've tried both of your methode script, tinstaafl's code is perfect for me, the result is correct when data is 1 digit till 3 digit (eg 1-123) but with replace 10 with 9 , for AndreRet's code, when data only 1 digit, it's cause error 13, mismatch data type (maybe "cm" in to the mid function, CMIIW), or may be i was wrong to copy your code, is it replace/completing the jarak = Mid(strFilter(I), 6, 3)? so the code become on your post?
Does strFilter(I) follow the same pattern as Text1.Text? If so the Val function will work for it too. If not it's just a matter of adjusting the parameters of the mid function inside the vall function.
@tinstaafl : strFilter (I) follow the same pattern as Text1.Text? dunno what you mean, the complete code just like my earlier post, with a little bit modification, removing one line code... but as i wrote before, your code works for me, just need to replace 10 with 9 in mid function.
I Developed application in C# with crystal reports and created setup file in third party (Advance) Installer.When i installed my application on client system application is working but ...