Sharing Visual Basic
hellow... thanks y udah kunjungin blog aq. disini aq posting beberapa tips tentang pemrograman visual basic, semoga bermanfaat
Selasa, 01 Desember 2015
Delete Parameter di Crystal Report
apakah anda pernah mengalami masalah ketika akan menghapus parameter dalam sebuah file crystal report?
Jumat, 20 Juni 2014
Membuat Input Box di vb6
Private Sub Cmdhapus_Click()
Dim xhapus As String
xhapus = InputBox("Ketik No. Cust yang akan di hapus", "Lookup")
If StrPtr(xhapus) = 0 Then
'Kode InputBox Cancel
'MsgBox "You pressed cancel!"
ElseIf Len(xhapus) = 0 Then
MsgBox "Anda Harus Mengisi Kode, tidak boleh kosong", vbInformation, "Hapus"
Else
Adocustomer.RecordSource = "select * from customer where nocust='" & Trim(xhapus) & "'"
Adocustomer.Refresh
If Adocustomer.Recordset.RecordCount > 0 Then
Adocustomer.Recordset.Delete
Adocustomer.Refresh
MsgBox "Data telah terhapus"
Else
MsgBox "No. Cust yang anda masukkan tidak ada"
End If
End If
Adocustomer.RecordSource = "select * from customer"
Adocustomer.Refresh
End Sub
Dim xhapus As String
xhapus = InputBox("Ketik No. Cust yang akan di hapus", "Lookup")
If StrPtr(xhapus) = 0 Then
'Kode InputBox Cancel
'MsgBox "You pressed cancel!"
ElseIf Len(xhapus) = 0 Then
MsgBox "Anda Harus Mengisi Kode, tidak boleh kosong", vbInformation, "Hapus"
Else
Adocustomer.RecordSource = "select * from customer where nocust='" & Trim(xhapus) & "'"
Adocustomer.Refresh
If Adocustomer.Recordset.RecordCount > 0 Then
Adocustomer.Recordset.Delete
Adocustomer.Refresh
MsgBox "Data telah terhapus"
Else
MsgBox "No. Cust yang anda masukkan tidak ada"
End If
End If
Adocustomer.RecordSource = "select * from customer"
Adocustomer.Refresh
End Sub
Senin, 16 Juni 2014
Pembulatan Angka
Dim Nilai As Double, Hasil As Long
Nilai = 1.4 'bilangan yg akan dibulatkan
Hasil = Int(Nilai) + IIf(CDbl(CStr(Nilai - Int(Nilai))) >= 0.4, 1, 0) 'Batas = 0,4
Selasa, 01 April 2014
Membatasi input Textbox hanya bisa diisi angka
If Not ((KeyAscii >= 48) And (KeyAscii <= 57) Or KeyAscii = 8) Then
KeyAscii = 0
End If
Kamis, 16 Januari 2014
Menghitung Sum & Count sebuah tabel dengan adodc
Private Sub CariTotal()
adototal.RecordSource = "select sum(debet) as vTotDeb,sum(kredit) as vTotKre from jurnal where day(tanggal)>= " & Day(CDate(TxtTglAwal.Value)) & " and day(tanggal)<= " & Day(CDate(TxtTglAkhir.Value)) & " and Month(tanggal)>= " & Month(CDate(TxtTglAwal.Value)) & " And Month(tanggal)<= " & Month(CDate(TxtTglAkhir.Value)) & " and Year(tanggal)>=" & Year(CDate(TxtTglAwal.Value)) & " and Year(tanggal)<=" & Year(CDate(TxtTglAkhir.Value)) & ""
adototal.Refresh
lblTotalDebet.Caption = adototal.Recordset!vTotDeb
lblTotalKredit.Caption = adototal.Recordset!vTotKre
End Sub
Private Sub cari_salah()
adoQbnrSlh.RecordSource = "select count(*) as hasil_slh from QBenarSalah where hasil='SALAH'"
adoQbnrSlh.Refresh
txtsalah.Text = adoQbnrSlh.Recordset!hasil_slh
End Sub
Private Sub cari_benar()
adoQbnrSlh.RecordSource = "select count(*) as hasil_bnr from QBenarSalah where hasil='BENAR'"
adoQbnrSlh.Refresh
txtbenar.Text = adoQbnrSlh.Recordset!hasil_bnr
End Sub
adototal.RecordSource = "select sum(debet) as vTotDeb,sum(kredit) as vTotKre from jurnal where day(tanggal)>= " & Day(CDate(TxtTglAwal.Value)) & " and day(tanggal)<= " & Day(CDate(TxtTglAkhir.Value)) & " and Month(tanggal)>= " & Month(CDate(TxtTglAwal.Value)) & " And Month(tanggal)<= " & Month(CDate(TxtTglAkhir.Value)) & " and Year(tanggal)>=" & Year(CDate(TxtTglAwal.Value)) & " and Year(tanggal)<=" & Year(CDate(TxtTglAkhir.Value)) & ""
adototal.Refresh
lblTotalDebet.Caption = adototal.Recordset!vTotDeb
lblTotalKredit.Caption = adototal.Recordset!vTotKre
End Sub
Private Sub cari_salah()
adoQbnrSlh.RecordSource = "select count(*) as hasil_slh from QBenarSalah where hasil='SALAH'"
adoQbnrSlh.Refresh
txtsalah.Text = adoQbnrSlh.Recordset!hasil_slh
End Sub
Private Sub cari_benar()
adoQbnrSlh.RecordSource = "select count(*) as hasil_bnr from QBenarSalah where hasil='BENAR'"
adoQbnrSlh.Refresh
txtbenar.Text = adoQbnrSlh.Recordset!hasil_bnr
End Sub
Rabu, 06 November 2013
Pembulatan Angka vb6
Private Function Genapkan(ByVal Number As Double, Optional Range = 100) As Double
Genapkan = (Round((Number / Range) + 0.49)) * Range
End Function
Private Sub Hitung()
On Error Resume Next
Dim v_sisa_harga As Double
Dim v_harga_angs As Double
Dim v_bunga As Double
Dim persen_bunga As Integer
persen_bunga = CInt(tbunga.Text)
v_sisa_harga = CDbl(tharga_jual.Text) - CDbl(tuangmuka.Text)
v_harga_angs = v_sisa_harga / CInt(tlamaangsuran.Text)
v_bunga = (persen_bunga / 100 * v_sisa_harga) ' / CInt(tlamaangsuran.Text)
tharga_angsuran = Genapkan(v_harga_angs + v_bunga)
ttotal_angsuran = CDbl(tharga_angsuran.Text) * CInt(tlamaangsuran.Text)
End Sub
Copy Image dari form ke sebuah folder
KODE UNTUK BROWSE IMAGE KE FORM
Private Sub CmdBrowse_Click()
CD.ShowOpen
imgfoto.Picture = LoadPicture(CD.FileName)
vFoto = CD.FileName
txtfotobahan.Text = vFoto
End Sub
KODE UNTUK MENG COPY IMAGE KE SEBUAH FOLDER
Private Sub simpan_foto()
If txtfotobahan.Text <> "" Then
adobahanbaku.Recordset!fotobahan = "D:\restoran\fotobahanbaku\" & txtkodebahan.Text & ".jpg"
SavePicture imgfoto.Picture, "D:\restoran\fotobahanbaku\" & txtkodebahan & ".jpg"
End If
End Sub
Langganan:
Postingan (Atom)