Rabu, 16 Maret 2016

APLIKASI VB UNTUK KONTROL 2 LAMPU (LED) ATAULEBIH

Tampilan Visual Basicnya
Tool Box yang digunakan:
  1. Frame
  2. Shape
  3. Check Box
  4. Combo Box
  5. Command Button
  6. MSComm
 Code Program:
Private Sub Check1_Click()
If Check1.Value = 1 Then
Shape1.FillColor = vbRed
MSComm1.Output = "a"
Else
Shape1.FillColor = &H40&
MSComm1.Output = "1"
End If
End Sub

Private Sub Check2_Click()
If Check2.Value = 1 Then
Shape2.FillColor = vbRed
MSComm1.Output = "b"
Else
Shape2.FillColor = &H40&
MSComm1.Output = "2"
End If
End Sub

Private Sub cmdconnect_Click()
MSComm1.CommPort = Val(Combo1.Text)
MSComm1.Settings = "9600,n,8,1"
MSComm1.PortOpen = True
MsgBox "Koneksi Berhasil !", vbInformation, "Sukses"
Frame1.Enabled = True
Combo1.Enabled = False
cmdconnect.Enabled = False
End Sub

Private Sub cmdexit_Click()
End
End Sub

Private Sub Form_Load()
For Port = 1 To 20
Combo1.AddItem Port
Next Port
Frame1.Enabled = False
MSComm1.Settings = "9600,n,8,1"
End Sub

Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub


Vidionya

Tidak ada komentar:

Posting Komentar