|
-
March 27th, 2001, 08:07 AM
#1
Please help. I'm new to VB
My program should send either a 1, 2, 3 or 4 to the serial port depending on whether volume +/- or channel +/- is selected. This is the code. It worked fine until I included the Communication code for channel up and channel dn. Please help. I'm using the enterprise version so I dont know why it doesn't work. Thanks.
Jarlath.
option Explicit
Dim S as Integer
private Sub frmRemote_load()
Image1.Visible = false
Image2.Visible = false
Image3.Visible = false
Image4.Visible = false
End Sub
private Sub cmdSpacebar_KeyPress(KeyAscii as Integer)
Timer.Enabled = false
Timer.Interval = 3000
Timer.Enabled = true
S = S + 1
If S = 5 then
S = 0
End If
If S = 1 then
lblStatus2.Caption = S
Image1.Visible = true
Image2.Visible = false
Image3.Visible = false
Image4.Visible = false
End If
If S = 2 then
lblStatus2.Caption = S
Image1.Visible = false
Image2.Visible = true
Image3.Visible = false
Image4.Visible = false
End If
If S = 3 then
lblStatus2.Caption = S
Image1.Visible = false
Image2.Visible = false
Image3.Visible = true
Image4.Visible = false
End If
If S = 4 then
lblStatus2.Caption = S
Image1.Visible = false
Image2.Visible = false
Image3.Visible = false
Image4.Visible = true
End If
If S = 0 then
lblStatus2.Caption = S
Image1.Visible = false
Image2.Visible = false
Image3.Visible = false
Image4.Visible = false
End If
End Sub
private Sub Timer_Timer()
If S = 1 then
lblStatus2.Caption = "Volume increasing"
Timer.Enabled = false
End If
If S = 2 then
lblStatus2.Caption = S
lblStatus2.Caption = "Volume decreasing"
End If
'output test for ch+ and ch- only
If S = 3 then
lblStatus2.Caption = S
lblStatus2.Caption = "Channel Up"
MSComm1.CommPort = 1
MSComm1.Settings = "9600,N,8,1"
MSComm1.PortOpen = true
MSComm1.Output = 3
'"ATDT555-1234" & vbCr
MSComm1.PortOpen = false
End If
If S = 4 then
lblStatus2.Caption = S
lblStatus2.Caption = "Channel Dn"
MSComm1.CommPort = 1
MSComm1.Settings = "9600,N,8,1"
MSComm1.PortOpen = true
MSComm1.Output = 4
MSComm1.PortOpen = false
End If
'Attempt1
S = 0
Image1.Visible = false
Image2.Visible = false
Image3.Visible = false
Image4.Visible = false
Timer2.Enabled = true
End Sub
private Sub Timer2_Timer()
lblStatus2.Caption = S
Timer2.Enabled = false
End Sub
-
March 29th, 2001, 05:36 PM
#2
Re: Please help. I'm new to VB
Output must be a string not numeric.
i.e.
MSComm1.Output = "3"
Regards,
Andy
-
March 30th, 2001, 09:40 AM
#3
Thanks for your reply.
You got me out of a real jam, with only a week left 'till my project deadline. The software works perfectly now.
Just in case you're curious, I'm designing a PC interfaced TV remote control for someone who has a physical disability (like a clubbed fist or something). Anyway, I'm off to build the external circuitry now! Thanks again.
Jarlath
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
|