Click to See Complete Forum and Search --> : Please help. I'm new to VB


jarlathreidy
March 27th, 2001, 07:07 AM
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

Andyb
March 29th, 2001, 04:36 PM
Output must be a string not numeric.
i.e.
MSComm1.Output = "3"

Regards,
Andy

jarlathreidy
March 30th, 2001, 08:40 AM
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