|
-
Nov 28th, 2002, 09:15 AM
#1
Thread Starter
Junior Member
I have the code below which reads in data from COM 1 into Excel, when you press the cmdRecord button in excel, but i would like to have a stop button to stop the process.
Any Ideas?
Thanks
#############
Dim value As Long
Dim ok As Boolean
Dim I As Integer
Dim port As Integer
Private Sub cmdRecord_Click()
port = 1
Cells(4, "I").value = "Opening ADC on COM" & port
ok = adc16_open_unit(port)
If ok Then
Cells(4, "I").value = "ADC opened"
' Specify 16-bit resolution for channels 1 and 2
ok = adc16_set_channel(port, 1, 10, True, 10)
ok = adc16_set_channel(port, 2, 10, True, 10)
' Get 50 readings from these channels
For I = 1 To 50
ticks = GetTickCount()
While GetTickCount() < ticks + 1000
' Let Excel carry on doing things
DoEvents
' Excel doesn't let timer ticks thru to adc16 driver...
' Must call the poll routine to keep data flowing
adc16_poll
Wend
ok = adc16_get_value(value, port, 1)
If ok Then
Cells(I + 17, "A").value = value * 2500 / 65535
Else
Cells(I + 17, "A").value = "****"
End If
ok = adc16_get_value(value, port, 2)
If ok Then
Cells(I + 17, "B").value = value * 2500 / 65535
Else
Cells(I + 17, "B").value = "****"
End If
Next I
' Close the driver
Call adc16_close_unit(port)
Else
Cells(4, "I").value = "Unable to open ADC"
End If
End Sub
##########
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
|