Monday, May 28, 2012

Memperoleh Jumlah Baris TextBox Menggunakan Fungsi API

<pre class=code>Option Explicit 

Private Declare Function
SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const
EM_GETLINECOUNT = &HBA

Public Function
GetLineCount(Txt As TextBox)
Dim lngLineCount As Long
On Error Resume Next
lngLineCount = SendMessageLong(Txt.hwnd, EM_GETLINECOUNT, 0&, 0&)
GetLineCount = Format$(lngLineCount, "##,###")
End Function</pre>


Private Sub Command1_Click() 
MsgBox GetLineCount(Text1)
End Sub
READ MORE - Memperoleh Jumlah Baris TextBox Menggunakan Fungsi API

Menjadikan Input TextBox Kapital

Option Explicit 

'This one line code makes the contents of text box in capital. As you keep in typing it. Just copy this code keypress
Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub
READ MORE - Menjadikan Input TextBox Kapital

Menjalankan File .MP3 Menggunakan Microsoft Multimedia Control

Option Explicit 

Private Sub
Command1_Click()
MMC.FileName = OpenFile
Me.Caption = MMC.FileName
MMC.Command = "open"
MMC.Command = "play"
End Sub

Private Function
OpenFile() As String
With
CommonDialog1
.FileName = ""
.DialogTitle = "Open Files"
.InitDir = "C:\My Documents"
.Filter = "MP3 File (*.MP3)|*.MP3"
.ShowOpen
If .FileName = "" Then Exit Function
MMC.Command = "stop"
OpenFile = .FileName
End With
End Function

Private Sub
Command2_Click()
MMC.Command = "stop"
End Sub
READ MORE - Menjalankan File .MP3 Menggunakan Microsoft Multimedia Control

Berapa Lama Windows Telah Dijalankan

Option Explicit 

Private Declare Function
GetTickCount Lib "Kernel32" () As Long

Private Sub
Timer1_Timer()
Text1.Text = Format(GetTickCount, "0") & " milisceconds"
Text2.Text = Format(GetTickCount / 60000, "0") & " minutes"
End Sub

READ MORE - Berapa Lama Windows Telah Dijalankan