|
SYNTAC PROGRAM HAL 1
Private Sub Command1_Click()
List1.Clear ‘ mengosongkan urutan huruf, agar tidak
‘ tercampur dgn urutan sebelumnya
myString = Text27.Text
tempString = Split(myString, “a”) ‘hitung jumlah a kecl
a = UBound(tempString)
tempString = Split(myString, “A”) ‘hitung jumlah A besar
ab = UBound(tempString)
Text1 = a + ab
tempString = Split(myString, “b”) ‘hitung jumlah b kecl
b = UBound(tempString)
tempString = Split(myString, “B”) ‘hitung jumlah B besar
bc = UBound(tempString)
Text2 = b + bc
tempString = Split(myString, “c”) ‘hitung jumlah c kecl
C = UBound(tempString)
tempString = Split(myString, “C”) ‘hitung jumlah C besar
cd = UBound(tempString)
Text3 = C + cd
tempString = Split(myString, “d”) ‘hitung jumlah d kecl
d = UBound(tempString)
tempString = Split(myString, “D”) ‘hitung jumlah D besar
de = UBound(tempString)
Text4 = d + de
tempString = Split(myString, “e”) ‘hitung jumlah e kecl
e = UBound(tempString)
tempString = Split(myString, “E”) ‘hitung jumlah E besar
ef = UBound(tempString)
Text5 = e + ef
tempString = Split(myString, “f”)
f = UBound(tempString)
tempString = Split(myString, “F”)
fg = UBound(tempString)
Text6 = f + fg
tempString = Split(myString, “g”)
g = UBound(tempString)
tempString = Split(myString, “G”)
gh = UBound(tempString)
Text7 = g + gh
tempString = Split(myString, “h”)
h = UBound(tempString)
tempString = Split(myString, “H”)
hi = UBound(tempString)
Text8 = h + hi
tempString = Split(myString, “i”)
i = UBound(tempString)
tempString = Split(myString, “I”)
ij = UBound(tempString)
Text9 = i + ij
tempString = Split(myString, “j”)
j = UBound(tempString)
tempString = Split(myString, “J”)
jk = UBound(tempString)
Text10 = j + jk
tempString = Split(myString, “k”)
k = UBound(tempString)
tempString = Split(myString, “K”)
kl = UBound(tempString)
Text11 = k + kl
tempString = Split(myString, “l”)
L = UBound(tempString)
tempString = Split(myString, “L”)
lm = UBound(tempString)
Text12 = L + lm
tempString = Split(myString, “m”)
m = UBound(tempString)
tempString = Split(myString, “M”)
mn = UBound(tempString)
Text13 = m + mn
tempString = Split(myString, “n”)
n = UBound(tempString)
tempString = Split(myString, “N”)
no = UBound(tempString)
Text14 = n + no
tempString = Split(myString, “o”)
o = UBound(tempString)
tempString = Split(myString, “O”)
op = UBound(tempString)
Text15 = o + op
tempString = Split(myString, “p”)
P = UBound(tempString)
tempString = Split(myString, “P”)
pq = UBound(tempString)
Text16 = P + pq
|
SYNTAC PROGRAM HAL 2
tempString = Split(myString, “q”)
q = UBound(tempString)
tempString = Split(myString, “Q”)
qr = UBound(tempString)
Text17 = q + qr
tempString = Split(myString, “r”)
r = UBound(tempString)
tempString = Split(myString, “R”)
rs = UBound(tempString)
Text18 = r + rs
tempString = Split(myString, “s”)
S = UBound(tempString)
tempString = Split(myString, “S”)
st = UBound(tempString)
Text19 = S + st
tempString = Split(myString, “t”)
t = UBound(tempString)
tempString = Split(myString, “T”)
tu = UBound(tempString)
Text20 = t + tu
tempString = Split(myString, “u”)
u = UBound(tempString)
tempString = Split(myString, “U”)
uv = UBound(tempString)
Text21 = u + uv
tempString = Split(myString, “v”)
V = UBound(tempString)
tempString = Split(myString, “V”)
vw = UBound(tempString)
Text22 = V + vw
tempString = Split(myString, “w”)
w = UBound(tempString)
tempString = Split(myString, “W”)
wx = UBound(tempString)
Text23 = w + wx
tempString = Split(myString, “x”)
x = UBound(tempString)
tempString = Split(myString, “X”)
xy = UBound(tempString)
Text24 = x + xy
tempString = Split(myString, “y”)
y = UBound(tempString)
tempString = Split(myString, “Y”)
yz = UBound(tempString)
Text25 = y + yz
tempString = Split(myString, “z”)
z = UBound(tempString)
tempString = Split(myString, “Z”)
za = UBound(tempString)
Text26 = z + za
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Command3_Click() ‘ memasukan hasil
‘ perhitungan ke urutan
List1.AddItem (Text1 & ” a buah”)
List1.AddItem (Text2 & ” b buah”)
List1.AddItem (Text3 & ” c buah”)
List1.AddItem (Text4 & ” d buah”)
List1.AddItem (Text5 & ” e buah”)
List1.AddItem (Text6 & ” f buah”)
List1.AddItem (Text7 & ” g buah”)
List1.AddItem (Text8 & ” h buah”)
List1.AddItem (Text9 & ” i buah”)
List1.AddItem (Text10 & ” j buah”)
List1.AddItem (Text11 & ” k buah”)
List1.AddItem (Text12 & ” l buah”)
List1.AddItem (Text13 & ” m buah”)
List1.AddItem (Text14 & ” n buah”)
List1.AddItem (Text15 & ” o buah”)
List1.AddItem (Text16 & ” p buah”)
List1.AddItem (Text17 & ” q buah”)
List1.AddItem (Text18 & ” r buah”)
List1.AddItem (Text19 & ” s buah”)
List1.AddItem (Text20 & ” t buah”)
List1.AddItem (Text21 & ” u buah”)
List1.AddItem (Text22 & ” v buah”)
List1.AddItem (Text23 & ” w buah”)
List1.AddItem (Text24 & ” x buah”)
List1.AddItem (Text25 & ” y buah”)
List1.AddItem (Text26 & ” z buah”)
Call ReSort(List1) ‘ mengurutkan huruf dari yang tersedikit ke yg terbanyak
End Sub
Sub ReSort(L As Control) ‘Fungsi untuk menyortir data
Dim P%, PP%, C%, Pre$, S$, V&, NewPos%, CheckIt%
Dim TempL$, TempItemData&, S1$
For P = 0 To L.ListCount – 1
S = L.List(P)
For C = 1 To Len(S)
V = Val(Mid$(S, C))
If V > 0 Then Exit For
Next
If V > 0 Then
If C > 1 Then Pre = Left$(S, C – 1)
NewPos = -1
For PP = P + 1 To L.ListCount – 1
CheckIt = False
S1 = L.List(PP)
If Pre <> “” Then
If InStr(S1, Pre) = 1 Then CheckIt = True
Else
If Val(S1) >= 0 Then CheckIt = True
End If
If CheckIt Then
If Val(Mid$(S1, C)) < V Then NewPos = PP
Else
Exit For
End If
Next
If NewPos > -1 Then
TempL = L.List(P)
TempItemData = L.ItemData(P)
L.RemoveItem (P)
L.AddItem TempL, NewPos
L.ItemData(L.NewIndex) = TempItemData
P = P – 1
End If
End If
Next
Exit Sub
End Sub
|