|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
|
|
#1
|
|||
|
|||
|
My Question Again
Private Sub Command1_Click()
On Error GoTo trap Dim timeout As Variant Dim sende As String Dim checksum As String Dim i MSCmm1.PortOpen = True Command1.Enabled = False sende = "" empfang = "" 'sende = Chr$(&H10) + Chr$(&H5B) + Chr$(&HFE) + Chr$(&H59) + Chr$(&H16) 'Direct communication for the CF-ECHO sende = Chr$(&H10) + Chr$(&H5B) + Chr$(&H1) + Chr$(&H5C) + Chr$(&H16) 'First external Communication attached to CF-ECHO MSCmm1.Output = sende timeout = Now() + 2 / 86400 Do DoEvents Loop Until Now() > timeout Print Len(empfang) Text1.Text = "" For i = 1 To Len(empfang) Text1.Text = Text1.Text + " " + HexByte(Asc(Mid(empfang, i, 1))) Next Print "Tv=", Val(HexByte(Asc(Mid(empfang, 51, 1))) + HexByte(Asc(Mid(empfang, 50, 1)))) / 10 Print "Return Temparature =", Val(HexByte(Asc(Mid(empfang, 55, 1))) + HexByte(Asc(Mid(empfang, 54, 1)))) / 10 Command1.Enabled = True MSCmm1.PortOpen = False trap: End Sub Private Sub MSCmm1_OnComm() empfang = empfang + MSCmm1.Input End Sub Private Function HexByte(b As Byte) As String Const HexChar = "0123456789ABCDEF" Dim upbit As Byte 'Upper Nibble Dim lowbit As Byte 'Lower Nibble upbit = b \ 16 lowbit = b Mod 16 HexByte = Mid(HexChar, upbit + 1, 1) + Mid(HexChar, lowbit + 1, 1) End Function The above code is working form for calculation of temparature from a device attached to com1 port and another two objects are connected,which delivers the required temparature. Now my problem is i must do the following Empfang function writing sende code for 1 to the empfang data receiving for sende code1 from the empfang function sende code for 2 to the empfang data receiving for sende code2 from the emfang function sende code for either 1 or 2 to use the empfang function to receive 1 & 2 sende together For which i do wrote the code like the following but i could not able to receive the output as i required Option Explicit Dim sende As String Dim i Private Function empfang(str As String) Dim timeout As Variant ' empfang = "" str = "" For i = 1 To Len(str) str = str + " " + HexByte(Asc(Mid(empfang, i, 1))) Next timeout = Now() + 2 / 86400 Do DoEvents Loop Until Now() > timeout Print Len(str) 'timeout = Now() + 2 / 86400 ' Do ' DoEvents ' Loop Until Now() > timeout ' Print Len(str) empfang = str End Function Private Function HexByte(b As Byte) As String 'This function a byte converts into Hex representation Const HexChar = "0123456789ABCDEF" Dim upbit As Byte 'Upper Nibble Dim lowbit As Byte 'Lower Nibble upbit = b \ 16 lowbit = b Mod 16 HexByte = Mid(HexChar, upbit + 1, 1) + Mid(HexChar, lowbit + 1, 1) 'Hex for representation for byte produce End Function Private Sub Command1_Click() Dim checksum As String Dim s As String MSCmm1.PortOpen = True Command1.Enabled = False sende = "" s = "" 'sende = Chr$(&H10) + Chr$(&H5B) + Chr$(&HFE) + Chr$(&H59) + Chr$(&H16) 'Direct communication for the CF-ECHO sende = Chr$(&H10) + Chr$(&H5B) + Chr$(&H1) + Chr$(&H5C) + Chr$(&H16) 'First external Communication attached to CF-ECHO Call empfang(sende) 'MSCmm1.Output = sende ''s = Val(HexByte(Asc(Mid(s, 51, 1))) + HexByte(Asc(Mid(s, 50, 1)))) / 10 's = 33 'Print HexByte(Asc(Mid(s, 51, 1))) ''Print "Tv=", Val(HexByte(Asc(Mid(s, 51, 1))) + HexByte(Asc(Mid(s, 50, 1)))) / 10 'Print "Return Temparature =", Val(HexByte(Asc(Mid(s, 55, 1))) + HexByte(Asc(Mid(s, 54, 1)))) / 10 Command1.Enabled = True MSCmm1.PortOpen = False 'trap: End Sub Private Sub Form_Load() MSCmm1.Settings = "9600, e, 8, 1" MSCmm1.CommPort = 1 End Sub |
|
#2
|
|||
|
|||
|
Hey
Can you tell me how i make a program in vb so i can call my pc from a phone and for example press 1 and then my pc restart?
Or do you know how i can call a phone and then play an audio file, i can make a program that call a phone, but what can i use i to, when im not can play an audio file.... hehe |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > My Question Again |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
![]() |
|