Cara Membuat Tips Of The Day VB6
https://carakuvb6.blogspot.com/2017/11/cara-membuat-tips-of-day-vb6.html
Tampilan Tips Of The Day saat kita mengoperasikan suatu aplikasi atau software pada umumnya berisi dekripsi tentang motivasi, tips, prosedur dan nasehat secara ringkas kepada user, akan tetapi tidak semua aplikasi mempunyai fasilitas Tips Of The Day hanya aplikasi-aplikasi tertentu saja, kali ini admin akan share sourcode tentang Cara Membuat Tips Of The Day VB6. Untuk interface dari sourcode ini seperti gambar dibawah ini
Buka Ms. Visual Basic 6.0 - StandarExe, kemudian buatlah sebuah form dan berikut komponen yang kita butuhkan dalam pembuatan sourcode diatas
Komponen
|
Name
|
Form1
|
frmTips
|
ClassModule1
|
cTip
|
ClassModule1
|
cTips
|
CommanButton1
|
cmdLainnya
|
CommanButton2
|
cmdOK
|
Label1
|
lblTip
|
Designlah interface dari form yang telah kita buat dengan ditambah beberapa komponen seperti Label, CommanButton kemudian copykan syntak dibawah ini ke ClassModule dengan name cTip
#Const ShowDebugMsgBox = False
Private m_sText As String
Private m_sID As String
Private m_dtCreated As Date
Public Property Let Text(sText As String)
m_sText = sText
End Property
Public Property Get Text() As String
Text = m_sText
End Property
Public Property Let ID(sID As String)
m_sID = sID
End Property
Public Property Get ID() As String
ID = m_sID
End Property
Public Property Get Created() As Date
Created = m_dtCreated
End Property
Private Sub Class_Initialize()
m_dtCreated = Now
#If ShowDebugMsgBox Then
MsgBox "Tip created: " & Created, vbInformation
#End If
End Sub
Private Sub Class_Terminate()
#If ShowDebugMsgBox Then
MsgBox "Tip: " & Created & " Error", vbInformation
#End If
End Sub
#Const ShowDebugMsgBox = False
Private m_sText As String
Private m_sID As String
Private m_dtCreated As Date
Public Property Let Text(sText As String)
m_sText = sText
End Property
Public Property Get Text() As String
Text = m_sText
End Property
Public Property Let ID(sID As String)
m_sID = sID
End Property
Public Property Get ID() As String
ID = m_sID
End Property
Public Property Get Created() As Date
Created = m_dtCreated
End Property
Private Sub Class_Initialize()
m_dtCreated = Now
#If ShowDebugMsgBox Then
MsgBox "Tip created: " & Created, vbInformation
#End If
End Sub
Private Sub Class_Terminate()
#If ShowDebugMsgBox Then
MsgBox "Tip: " & Created & " Error", vbInformation
#End If
End Sub
Selanjutnya pada ClassModule dengan name cTips
Private m_colTips As New Collection
Public Function Add(sText As String) As cTip
Dim tipNew As New cTip
Static iID As Integer
With tipNew
iID = iID + 1
.ID = "T" & Format$(iID, "00000")
.Text = sText
m_colTips.Add tipNew, .ID
End With
Set Add = tipNew
End Function
Public Function Count() As Long
Count = m_colTips.Count
End Function
Public Sub Delete(vKey As Variant)
m_colTips.Remove vKey
End Sub
Public Function NextTip() As String
Static iLast As Integer
iLast = iLast + 1
If iLast > Me.Count Or iLast < 1 Then
iLast = 1
End If
NextTip = m_colTips(iLast).Text & TipNumber(iLast)
End Function
Public Function RandomTip() As String
Dim iRandom As Integer
Randomize
iRandom = Int((Me.Count) * Rnd + 1)
RandomTip = m_colTips(iRandom).Text & TipNumber(iRandom)
End Function
Private Function TipNumber(iTheNumber As Integer) As String
TipNumber = Chr$(13) & Chr$(13) & "Tip " & iTheNumber
End Function
Private Sub Class_Initialize()
Me.Add "Selamat Datang Di Program Tips Kami"
Me.Add "Belajarlah Tanpa Henti"
Me.Add "Gali Terus Potensi Diri"
Me.Add "Jangan Pernah Menyerah dan Pantang Mundur, Kalo ada jurang ya mundur gan !!!, kalo maju terus berarti ente konyol heeehee !!"
End Sub
Private m_colTips As New Collection
Public Function Add(sText As String) As cTip
Dim tipNew As New cTip
Static iID As Integer
With tipNew
iID = iID + 1
.ID = "T" & Format$(iID, "00000")
.Text = sText
m_colTips.Add tipNew, .ID
End With
Set Add = tipNew
End Function
Public Function Count() As Long
Count = m_colTips.Count
End Function
Public Sub Delete(vKey As Variant)
m_colTips.Remove vKey
End Sub
Public Function NextTip() As String
Static iLast As Integer
iLast = iLast + 1
If iLast > Me.Count Or iLast < 1 Then
iLast = 1
End If
NextTip = m_colTips(iLast).Text & TipNumber(iLast)
End Function
Public Function RandomTip() As String
Dim iRandom As Integer
Randomize
iRandom = Int((Me.Count) * Rnd + 1)
RandomTip = m_colTips(iRandom).Text & TipNumber(iRandom)
End Function
Private Function TipNumber(iTheNumber As Integer) As String
TipNumber = Chr$(13) & Chr$(13) & "Tip " & iTheNumber
End Function
Private Sub Class_Initialize()
Me.Add "Selamat Datang Di Program Tips Kami"
Me.Add "Belajarlah Tanpa Henti"
Me.Add "Gali Terus Potensi Diri"
Me.Add "Jangan Pernah Menyerah dan Pantang Mundur, Kalo ada jurang ya mundur gan !!!, kalo maju terus berarti ente konyol heeehee !!"
End Sub
Kemudian double klik pada form pilih prosedur (General) dan (Declarations) copy syntak dibawah ini
Private m_colTips As cTips
Private m_colTips As cTips
Selanjutnya double klik lagi pada form pilih prosedur Form_Load dan copykan syntak dibawah ini
Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
Set m_colTips = New cTips
lblTip = m_colTips.RandomTip
Masih didalam form lalu pilih prosedur Form_Unload dan copykan syntak dibawah iniMove (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
Set m_colTips = New cTips
lblTip = m_colTips.RandomTip
Set m_colTips = Nothing
Set frmTips = Nothing
Selanjutnya double klik pada tombol Tips Selanjutnya dan copykan syntak dibawah ini
Dim sTip As String
sTip = lblTip
While sTip = lblTip
sTip = m_colTips.NextTip
Wend
lblTip = sTip
Setelah selesai simpan dan RUN/F5 coba klik Tips Selanjutnya beberapa kali, maka Tips akan bergantian muncul dengan urutan nomor yang berbeda. Sourcodenya bisa didwonload di LINK INI semoga artikel kali ini bermanfaat bagi pembaca
Perhatian !!
- Berkomentarlah dengan menggunakan bahasa yang baik dan sopan dan sesuai topik pembahasan
- Dilarang menjadikan referensi artikel web ini tanpa menyertakan sumbernya