Upload
independent
View
11
Download
0
Embed Size (px)
Citation preview
Nomor 1
Private Sub Command1_Click()If Not MSCom m1.PortOpen ThenMSComm1.PortOpen = TrueMsgBox ("Port dibuka")ElseMsgBox ("Port telah dibuka"), , "Pesan Kesalahan"End IfEnd Sub
Nomor 2
Private Sub Form_Load()If Not MSComm1.PortOpen ThenMSComm1.PortOpen = TrueElseMsgBox ("Port digunakan oleh progam Lainnya")End IfEnd Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)If KeyCode = 13 ThenText1(Index).Text = Format(Text1(Index).Text, "hh:mm:ss")End IfEnd Sub
Private Sub Timer1_Timer()Dim i As IntegerLabel1.Caption = Format(Time, "Hh:Mm:Ss")For i = 0 To 4If Check1(i).Value And (Label1.Caption = Text1(i).Text) ThenMSComm1.DTREnable = FalseTimer2.Enabled = TrueEnd IfNext iIf MSComm1.DTREnable ThenShape1.BackColor = &H80ElseShape1.BackColor = &HFFEnd IfEnd Sub
Private Sub Timer2_Timer()
MSComm1.DTREnable = TrueIf MSComm1.DTREnable ThenShape1.BackColor = &H80ElseShape1.BackColor = &HFFEnd IfTimer2.Enabled = FalseEnd Sub
Nomor 3
Option Explicit
Private Sub Delay()Dim a As Single a = Timer + 0.01 Do While a > Timer DoEvents LoopEnd Sub
Private Sub cmdln_Click()Dim tmp As String MSComm1.DTREnable = True Delay MSComm1.DTREnable = False Delay If MSComm1.InBufferCount > 0 Then tmp = MSComm1.Input TxtIn.Text = Hex(Asc(tmp)) End IfEnd Sub
Private Sub Form_Load()MSComm1.CommPort = 1
MSComm1.Settings = "57600,n,8,1"MSComm1.PortOpen = TrueMSComm1.DTREnable = FalseEnd Sub
Nomor 4
Option Explicit
Private Sub cmdout_Click()MSComm1.Output = Chr(Val("&H" & Txtout.Text) Mod 256)End Sub
Private Sub Form_Load()MSComm1.CommPort = 1MSComm1.Settings = "57600,n,8,1"MSComm1.PortOpen = TrueEnd Sub
Nomor 5
Option ExplicitDim flgrun As Boolean
Private Sub cmdrun_Click()Dim buffer(0) As ByteDim i As ByteIf cmdrun.Caption = "run" Thencmdrun.Caption = "stop"
flgrun = TrueElsecmdrun.Caption = "run"flgrun = FalseExit SubEnd IfHIDComm.ReportID = 1Do While flgrunFor i = 0 To 7buffer(0) = 2 ^ iHIDComm.WriteTo buffer, 1hp.Delay_ms 100NextLoopEnd Sub
Private Sub Form_Load()Dim buffer(0) As ByteHIDComm.MatchManufacturer = "innovative experiment"HIDComm.MatchProduct = "U-Board USB 1.0/1.1 Interface"HIDComm.MatchSerial = 0HIDComm.MatchPID = 4095HIDComm.MatchVID = 1240HIDComm.MatchVersion = 256HIDComm.ConnectHIDComm.ReportID = 1buffer(0) = &H0HIDComm.WriteTo buffer, 1End Sub
Unguided
Option Explicit
Dim flgrun As BooleanDim biner As StringDim bin1 As StringDim bin2 As StringDim hasil1 As IntegerDim hasil2 As IntegerDim gabung As StringDim hex1 As StringDim hex2 As StringDim tampung As IntegerDim i As Integer
Private Sub cmdrun_Click()
If cmdRun.Caption = "Run" Then For i = 0 To 7 If Check1(i).Value = Checked Then biner = biner + "1" Else biner = biner + "0" End If Next i bin1 = Left(biner, 4) bin2 = Mid(biner, 5, 4) For i = 4 To 1 Step -1 If Mid(bin1, i, 1) = "1" Then hasil1 = hasil1 + 2 ^ (4 - i) End If
Next For i = 4 To 1 Step -1 If Mid(bin2, i, 1) = "1" Then hasil2 = hasil2 + 2 ^ (4 - i) End If Next Select Case hasil1 Case 10: hex1 = "A" Case 11: hex1 = "B" Case 12: hex1 = "C" Case 13: hex1 = "D" Case 14: hex1 = "E" Case 15: hex1 = "F" Case Else hex1 = hasil1 End Select Select Case hasil2 Case 10: hex2 = "A" Case 11: hex2 = "B" Case 12: hex2 = "C" Case 13: hex2 = "D" Case 14: hex2 = "E" Case 15: hex2 = "F" Case Else hex2 = hasil2 End Select gabung = hex1 + hex2 Timer2.Enabled = True cmdRun.Caption = "Stop" flgrun = True Else Timer1.Enabled = False Timer2.Enabled = False cmdRun.Caption = "Run"
flgrun = False
Exit Sub End IfEnd Sub
Private Sub Command3_Click()End
End Sub
Private Sub Form_Load()MSComm1.CommPort = 1MSComm1.Settings = "57600,n,8,1"MSComm1.PortOpen = True
End Sub
Private Sub Timer1_Timer()tampung = Val(Label6.Caption)If tampung < 10 ThenLabel6.Caption = tampung + 1
ElseLabel6.Caption = 1
End IfEnd Sub
Private Sub Timer2_Timer()If Label6.Caption = Text1.Text Then
MSComm1.Output = Chr(Val("&H" & gabung))hp.Delay_ms Val(Text2.Text)MSComm1.Output = Chr(Val(&H0))
End IfEnd Sub