Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15919

serial port read

$
0
0
Friends I am new to vb6. i am doing project. ol. help me.
i am sanding data from key board like 00,01, 02,03,04,05 ...... up to 32
as per serial port in put i play wav file =using MM Control.
code is attach here with... and i am getting result also

code:


Private Sub Form_Load()

' Fire Rx Event Every single Bytes
MSComm1.RThreshold = 8

' When Inputting Data, Input 1 Byte at a time
MSComm1.InputLen = 8

' 9600 Baud, No Parity, 8 Data Bits, 1 Stop Bit
MSComm1.Settings = "9600,N,8,1"
' Disable DTR
MSComm1.DTREnable = False

' Open COM1
MSComm1.CommPort = 1
MSComm1.PortOpen = True

End Sub
Private Sub MSComm1_OnComm()

Dim Data As String
Dim file As String
' Dim Data() As Byte
' If comEvReceive Event then get data and display
If MSComm1.CommEvent = comEvReceive Then
Data = MSComm1.Input 'get data
Lbldata.Caption = Data 'convert to ASCII and display
Data2 = ""
For i = 1 To Len(Data)
x = Left(Data, 1)
Data = Right(Data, Len(Data) - 1)
If i = 2 Or i = 3 Then Data2 = Data2 & x


Next
Text1.Text = Data2
file = "C:\Users\Administrator\Desktop\bh prog\n1" & Data2 & ".wav"
Text2.Text = file
End If


MMControl1.Visible = False
MMControl1.Notify = False
MMControl1.Wait = True
MMControl1.Shareable = False
MMControl1.DeviceType = "WaveAudio" 'specifying which type of audio is
MMControl1.FileName = Text2 ' path of audio
MMControl1.Command = "Open" ' default open
MMControl1.Command = "Play" ' play command
MMControl1.Command = "wait"
'MMControl1.Command = "stop"

End Sub





now i want if i press 01 first and then 02 then it should play file 01.wav aqnd then 02.wav.

if nothing after 01 then only file 01

if 00 is pressed then no wav file will play..

Viewing all articles
Browse latest Browse all 15919

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>