Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to see the value from this vba code?

Status
Not open for further replies.

Fekri

Programmer
Jan 3, 2004
284
IR
Hi,

I'm very confuse because of thinking about where I have to put this question?

I'm searching for the way to see data from weighing machine and I found many sites and many vba codes which all of them explain how to read serial port, but I don't know how I can see the weight data in the text box in my form??

can any body explain me how these codes works?
and what I should do in my forms to use these codes and see the weighing machine??

Thanks
Ali

Thanks & Good Luck
Ali Fekri
 
how these codes works?
Which codes ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
thanks PHV as usual you are coming to help me..

Thanks

one of them is :

Private Sub cmdOpenPort_Click()
PortName = VBA.Right(Me.cboPorts.Value, 1)
x = Me.intBaudRate
PortSetting = x & "," & Me.txtParity & "," _
& Me.intDataBits & "," & Me.intStopBits
' Open the serial port
MSComm1.CommPort = PortName
MSComm1.Settings = PortSetting
MSComm1.Handshaking = Me.txtHandShake
MSComm1.InputLen = 0
MSComm1.PortOpen = True
'Check buffer,
If (MSComm1.InBufferCount > 0) Then
strTimerInput = MSComm1.Input
End If
Me.TimerInterval = 1000

MsgBox "Port is Open," & _
vbLf & "Please Turn on your timer" & _
vbCr & "Release starting gate, and trigger timer for test."

End Sub

Private Sub Form_Timer()
Dim intcounter As Integer
Dim temp, a, b, c, d, e, f

b = "B"
c = "C"
d = "D"
e = "E"
f = "F"

If (MSComm1.InBufferCount > 0) Then
strTimerInput = "" 'txtTestData.value
strTimerInput = MSComm1.Input 'strTimerInput & MSComm1.Input
txtTestData.SetFocus
txtTestData.Value = strTimerInput
temp = VBA.Mid(txtTestData, 1, 1)
If temp = "A" Then 'Buffer has race data
Lane6.Value = VBA.Mid(txtTestData, 3, 5)
temp = InStr(1, txtTestData, b)
Lane5.Value = VBA.Mid(txtTestData, temp + 2, 5)
temp = InStr(1, txtTestData, c)
Lane4.Value = VBA.Mid(txtTestData, temp + 2, 5)
temp = InStr(1, txtTestData, d)
Lane3.Value = VBA.Mid(txtTestData, temp + 2, 5)
temp = InStr(1, txtTestData, e)
Lane2.Value = VBA.Mid(txtTestData, temp + 2, 5)
temp = InStr(1, txtTestData, f)
Lane1.Value = VBA.Mid(txtTestData, temp + 2, 5)
MsgBox "Test Data Recieved," & _
vbCr & "If you are satisfied with readings" & _
vbCr & "Please Save Port details for Race Configuration"
End If
End If

End Sub


And also I found the way to use in macro in excel:


thanks for your help

Thanks & Good Luck
Ali Fekri
 
Also I found this thread thread702-593810
which deulyd explained perfectly..

the only thing which I couldn't find is: he told in this thread, that I have to write his code in "OnComm" event which I couldn't find on Mscomm control!!!!

it has no this name event!!

UPdate event
enter event
exit event
gotfocus
lost focus

is the only events on it!!!
I can not find his e-mail address, to contact directly to him.
but if any body knows what was his mean, I will appreciated.


thanks for any help
Ali

Thanks & Good Luck
Ali Fekri
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top