求助编程vb 100
Dim a As String, b(20) As String, c(20) As Integer
Dim max As Integer, k As Integer
Private Sub Command1_Click()
a = Text1.Text
i = 1
k = -1
max = -1
While i <= Len(a)
While i <= Len(a) And Mid(a, i, 1) < "A" Or Mid(a, i, 1) > "Z" And Mid(a, i, 1) < "a" Or Mid(a, i, 1) > "z"
i = i + 1
Wend
j = i
While i <= Len(a) And (Mid(a, i, 1) >= "A" And Mid(a, i, 1) <= "Z" Or Mid(a, i, 1) >= "a" And Mid(a, i, 1) <= "z")
i = i + 1
Wend
If i > j Then
k = k + 1
c(k) = i - j
b(k) = Mid(a, j, c(k))
If max < c(k) Then max = c(k)
Text2.Text = Text2.Text & b(k) & vbCrLf
End If
Wend
End Sub
Private Sub Command2_Click()
For i = 1 To k
If c(i) = max Then
Text3.Text = Text3.Text & b(i) & vbCrLf
End If
Next i
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text1.FontSize = 13
Text1.FontBold = True
Text2.Text = ""
Text2.FontSize = 13
Text2.FontBold = True
Text3.Text = ""
Text3.FontSize = 13
Text3.FontBold = True
End Sub
Private Sub Command1_Click()
Dim st As String, wd As String
Dim s() As String, top As Integer, i As Integer
top = 1
wd = ""
ReDim s(1 To top) As String
st = Text1.Text
st = Replace(st,".","") + " "
Do While Not st = ""
If Left(st, 1) <> " " Then
wd = wd + Mid(st, 1, 1)
Else
If Len(wd) > Len(s(top)) Then
top = 1
s(top) = wd
ReDim Preserve s(1 To 1)
ElseIf Len(wd) = Len(s(top)) Then
top = top + 1
ReDim Preserve s(1 To top)
s(top) = wd
End If
List1.AddItem wd
wd = ""
End If
st = Right(st, Len(st) - 1)
Loop
List1.AddItem wd
For i = 1 To top
List2.AddItem s(i)
Next i
End Sub
测试通过,只需将一个列表框替换成文本框,略改一下代码即可。
这个给你,你自己看。
什么