Popular Posts

Kamis, Juli 30, 2009

Menghitung Jumlah Karakter, Kata dan Spasi Dalam Textbox di Visual Basic

Berikut adalah langkah Langkah menghitung jumlah kata, jumlah karakter, jumlah spasi dalam textbox dan merubah huruf kecil menjadi huruf besar di Vusial Basic
Pertama kita buat tampilan form sebagai berikut


Private Sub Command1_Click() 'jalan
Dim i, jmlA, jmlB As Integer
Dim a, b As String
Dim nItem As Integer
Dim aItem As Variant
Dim sTeks As String
If Text1.Text = "" Then
Text1.SetFocus
Exit Sub
End If

'Tampilkan Jumlah Kata
a = Text1.Text
jmlA = 1
For i = 1 To Len(Trim$(a))
If Asc(Mid(a, i, 1)) = 13 Or Asc(Mid(a, i, 1)) = 32 Then jmlA = jmlA + 1
Next i
Text2 = jmlA

'Tampilkan Jumlah Karakter
Text3 = Len(Text1)

'Tampilkan Jumlah spasi
sTeks = Text1
aItem = Split(sTeks, " ")
nItem = UBound(aItem)
Text4 = nItem

'Ganti Huruf
If Text1.Text = LCase$(Text1) Then
Text5.Text = UCase$(Text1)
Else
Text5.Text = LCase$(Text1)
End If
End Sub

Private Sub Command2_Click() 'keluar
If MsgBox("Keluar?", vbQuestion + vbOKCancel) = vbOK Then End
End Sub

Private Sub Command3_Click() 'clear
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text1.SetFocus
End Sub

Download Project Lengkapnya>> Program Textbox.rar

Comments :

0 komentar to “Menghitung Jumlah Karakter, Kata dan Spasi Dalam Textbox di Visual Basic”


Posting Komentar