7,789
社区成员
发帖
与我相关
我的任务
分享Private Sub Command1_Click()
Label1 = Remove_repeated_characters(Text1.Text)
End Sub
Private Sub Command2_Click()
Label1 = Remove_continuous_characters(Text1.Text)
End Sub
Private Sub Form_Load()
Text1 = "FuDdan, fuuDdaaa, FFuuDDDaaa"
End Sub
Private Function Remove_repeated_characters(ByVal strSource As String) As String
Dim i As Long, j As Long, tmp As String, strResult As String
strResult = Left(strSource, 1)
For i = 2 To Len(strSource)
tmp = Mid(strSource, i, 1)
If tmp = "," Or tmp = "" Then
strResult = strResult & tmp
Else
For j = 1 To Len(strResult)
If tmp = Mid(strResult, j, 1) Then Exit For
Next j
If j > Len(strResult) Then strResult = strResult & tmp
End If
Next i
Remove_repeated_characters = strResult
End Function
Private Function Remove_continuous_characters(ByVal strSource As String) As String
Dim i As Long, strResult As String
strResult = Left(strSource, 1)
For i = 2 To Len(strSource)
If Mid(strSource, i, 1) <> Mid(strSource, i - 1, 1) Then strResult = strResult & Mid(strSource, i, 1)
Next i
Remove_continuous_characters = strResult
End Function
Option Explicit
Private Sub Command1_Click()
Dim strText As String
Dim strTemp As String
Dim strChar As String
strTemp = Text1.Text
strText = ""
Do
If ("" = strTemp) Then Exit Do
strChar = Mid$(strTemp, 1, 1)
strText = strText & strChar
strTemp = Replace(strTemp, strChar, "")
Loop
Me.Cls
Me.Print strText ' 你的作业中是赋值给某 Label
End Sub
Private Sub Command2_Click()
Dim strText As String
Dim strChar As String
Dim i&, p&, w As Long
strText = Text1.Text
w = Len(strText)
p = 0&: i = 1&
Do
If (i > w) Then Exit Do
strChar = Mid$(strText, i, 1)
For i = 1& + i To w
If (strChar <> Mid$(strText, i, 1)) Then Exit For
Next
p = 1& + p
Mid$(strText, p) = strChar
Loop
Me.Cls
Me.Print Left$(strText, p) ' 你的作业中是赋值给某 Label
End Sub


[/quote]
改成了也是没有结果。。。[/quote]
不可能,除非你的 TextBox1 本来就是“空的”!
另外,自己在 Do循环之前设置一个断点,然后单步跟踪运行一下,看看究竟是哪儿“不正确”啊。
[/quote]这样是可以的,但是最后导出的结果,比如输入的是rrwwrrt,输出的是rwt
[/quote]
改成了也是没有结果。。。[/quote]
不可能,除非你的 TextBox1 本来就是“空的”!
另外,自己在 Do循环之前设置一个断点,然后单步跟踪运行一下,看看究竟是哪儿“不正确”啊。

[/quote]
改成了也是没有结果。。。
