so many browser spread in internet.
wow, vb can make it too, even it's so easy.
we need an object called Microsoft Internet Controls.
this object defaultly installed when we install vb.
here is some code..
Private Sub Command1_Click()
End
End Sub
Private Sub Form_Load()
'show web file
web.Navigate App.Path & "\contoh.htm"
End Sub
Friday, November 9, 2007
web viewer like browser
Diposting oleh adi_vb di 3:36 AM 1 komentar
Label: web browser
read write ini file
some application need configuration setting.
usually we use ini file in windows system.
vb can do both read and write ini file.
here is code for read/write ini file.
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias _ "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As _ Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize _
As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" _
Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Const ini_file = "C:\contoh.ini"
Private Sub Command1_Click()
'this code will save from di Text1
'under section 'coba' on Key 'oke'.
hasil = WritePrivateProfileString("coba", "oke", Text1.Text, ini_file)
End Sub
Private Sub Command2_Click()
Dim my_val As String * 20
'this code will get from key 'oke' under section 'coba',
'and give to variable named my_val.
hasil = GetPrivateProfileString("coba", "oke", "Empty", my_val, Len(my_val),ini_file)
MsgBox my_val, vbInformation, "ok"
End Sub
click here to download the project...
Diposting oleh adi_vb di 3:26 AM 0 komentar
Label: ini file
show hidden file
so many virus or worm that attack our file or folder.
one of its attack is hide our file or folder.
they usually make our file hidden and system file.
here is some code to make it show again.
we only use dos command to resolve this problem.
here is the code...
1. get in to command dos (Start>Run>type ‘cmd’)
2. suppost the drive that we want to recover is f, so type "f:" (enter)
3. type “attrib –s –h /s /d *” push enter
4. that's all, all file or folder will show up again…
have a nice try…
Diposting oleh adi_vb di 3:09 AM 0 komentar
Label: show hidden file or folder
Login with database
Oke, now we try to make a login form.
but, we use database to store user name and password...
i use ms access 2003 to build the database.
in this application, there are 2 form. 1 for login and other for display the data.
here, the code...
#1) login form
Private Sub Command1_Click()
Adodc1.RecordSource = "select * from data_user where user_name='" & Text1.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.RecordSource = "select * from data_user where user_name='" & Text1.Text & "' and kode_password='" & Text2.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
'benar
Unload Me
Load Form2
Form2.Show
Else
MsgBox "Password salah!", vbInformation, "salah"
Text2.Text = ""
Text2.SetFocus
End If
Else
MsgBox "user name salah!", vbInformation, "salah"
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
sumber = App.Path & "\login.mdb"
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sumber & ";Persist Security Info=False"
Adodc1.RecordSource = "select * from data_user"
Adodc1.Refresh
End Sub
#2) data form
Private Sub Command1_Click()
End
End Sub
Private Sub Form_Load()
sumber = App.Path & "\login.mdb"
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sumber & ";Persist Security Info=False"
Adodc1.RecordSource = "select * from data_user"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
.....
click here to download...
Diposting oleh adi_vb di 1:24 AM 0 komentar
Label: login with database
Login for Access Application
OK, its very easy make a login form for any application with vb (of course).
Here i make count if any mistakes of entry both user name or password.
User only 3 times to try. If 3 times mistakes, so the form will terminated!
Of course, it will show a message if there's a mistakes...
here, the code...
Dim salah As Byte
Private Sub Command1_Click()
If Text1.Text = "adi" And Text2.Text = "vb" Then
MsgBox "Login sukses!", vbInformation, "oke"
Else
MsgBox "Login gagal!", vbCritical, "no"
salah = salah + 1
If salah = 3 Then
MsgBox "Anda sudah salah 3x!" & Chr(10) & "Aplikasi akan mati!", vbInformation, "look"
End
End If
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End If
End Sub
Private Sub Command2_Click()
End
End Sub
click here to download...
Diposting oleh adi_vb di 1:17 AM 0 komentar
Label: login vb
Syntax SQL for querying database
SQL (Structured Query Language) is a small-language that we can use to manipulate a database. In real life, SQL equivalent with lingua-france (language of trade).
Almost database application recognize this language.
So, if we good in this language, it very useful for our application that related with database. Of cource, most application related with database.
Suppost we have table: "data_pegawai"
here the record...
--------------------------------------------
nip nama alamat usia gender
--------------------------------------------
001 joko depok 50 L
002 soni bogor 35 L
003 dewi jakarta 20 P
004 rudi depok 30 L
--------------------------------------------
here...some SQL syntax...
if we want to display all record...
"select * from data_pegawai"
if we want to display only nip and nama...
"select nip,nama form data_pegawai"
if we want to display person who only usia > 30...
"select * from data_pegawai where usia > 30"
if we want to display only alamat in depok...
"select * from data_pegawai where alamat='depok'"
if we want to know how many person in each alamat...
"select alamat,count(alamat) as jumlah from data_pegawai group by alamat"
...that's an example....i will continue later...
Diposting oleh adi_vb di 1:01 AM 0 komentar
Label: SQL statement
count date different (selisih tanggal)
with vb, its very easy to calculate the different between two date.
we can count the different based on day or month.
we need dtpicker object. it object is a member of microsoft windows common control 2-6.0
here is the source code...
Private Sub Command1_Click()
If Option2.Value = True Then
Text1.Text = DateDiff("m", tgl1.Value, tgl2.Value)
Label4.Caption = "Bulan"
Else
Text1.Text = DateDiff("d", tgl1.Value, tgl2.Value)
Label4.Caption = "Hari"
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Option3.Value = True
tgl1.Value = Now
tgl2.Value = Now
End Sub
click here to download...
Diposting oleh adi_vb di 12:27 AM 0 komentar
Label: datediff vb
Thursday, November 8, 2007
billing rental/warnet single pc
we can make a billing for pc rental or internet rental (warnet).
we can use object timer in vb.
maybe we need to give them a password form; to end or stop application.
in this application we need 2 forms; 1 for billing and 1 for password.
here is some its source code...
'this is code for billing form...
Dim mulai As Single
Dim keluar As Single
Dim biaya As Long
Dim hitung As Integer
Private Sub Command1_Click()
biaya = 500
Text3.Text = "500"
mulai = Time
keluar = Time
Text1.Text = Format(Time, "hh:mm:ss")
Timer1.Enabled = True
Command1.Enabled = False
Command2.Enabled = True
End Sub
Private Sub Command2_Click()
Load password
password.Show
End Sub
Private Sub Form_Resize()
If Me.WindowState = 1 Then
Me.Caption = Text2.Text
Else
Me.Caption = "Billing PC-10"
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Load password
password.Show
password.Caption = "Close"
Cancel = 1
End Sub
Private Sub Timer1_Timer()
hitung = hitung + 1
keluar = keluar + 0.00001157448
Text2.Text = Format(keluar - mulai, "hh:mm:ss")
If hitung Mod 480 = 0 Then
biaya = biaya + 500
Text3.Text = Format(biaya, "###,###,###")
hitung = 0
End If
If Me.WindowState = 1 Then
Me.Caption = Text2.Text
End If
End Sub
'this code for password form...
Private Sub Command1_Click()
If Me.Caption = "Close" Then
If Text1.Text = "aadc" Then
End
End If
Else
If Text1.Text = "aadc" Then
Form1.Timer1.Enabled = False
Form1.Command1.Enabled = True
Form1.Command2.Enabled = False
End If
End If
Unload Me
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command1_Click
End If
End Sub
click here to download...
Diposting oleh adi_vb di 11:52 PM 0 komentar
Label: billing internet, billing rental
stop watch by vb
here is i make a small application from vb.
i make a stop watch...
we can use object timer.
there are a few methods or properties that we must set if we want to use a timer.
they are: interval (to determine time interval of timer counting) and enabled (to run/stop timer).
here is some simple code to utilize timer object...
'vb code
private sub command1_click()
'set interval
timer1.interval=1000 '1000=1 second
'start timer
timer1.enabled=true
end sub
private sub command2_click()
'stop timer
timer1.enabled=false
end sub
click here to download full application...
Diposting oleh adi_vb di 10:31 PM 0 komentar
Label: stop watch vb
adodc connectionstring for any database
visual basic 6 has many capabilities to connect with many database application.
both desktop database and client-server database.
such as: ms access, foxpro, dbase, sql server, etc.
with these capabilities, make vb mostly used by many programmer related with database application.
to connect with database, we need object connector, adodc.
in adodc, there are 2 methods that we must set to make adodc connect with database.
they are: connectionstring and recordsource.
we use connectionstring to determine what database application and the name of our database. while recordsource, we use it to select a table.
here some adodc connectionstring....(i've repost it from pondokindah.wordpress.com. thanks)
Diposting oleh adi_vb di 6:55 PM 0 komentar
Label: adodc connectionstring