# Re: vb一问

Posted by 哈林 on February 11, 1999 at 23:19:58:

In Reply to: vb一问 posted by err on February 11, 1999 at 13:46:19:

请测试以下的程式码:
请先在From上放置一Text Box 和两个Label
Dim nArr()
Dim i As Long
Dim j As Long
Dim k As Long
Dim l As Long
Dim sStr As String
Dim sVal1 As String
Dim sVal2 As String
Dim cFlag As Boolean

Private Sub Form_Load()
sStr = "1234567890,.1/;':@#$%^*()_+|[]{}" & """" & "&&"
Label2.Caption = sStr
cFlag = False
i = 1
End Sub

Private Sub Label1_Click()
If Text1.Text <> "" Then
For i = 1 To Len(Text1.Text)
sVal1 = Mid(Text1.Text, i, 1)
For j = 1 To Len(sStr)
sVal2 = Mid(sStr, j, 1)
If cFlag = False Then
If sVal2 = sVal1 Then
cFlag = True
Else
cFlag = False
End If
End If
Next j
If cFlag = False Then
ReDim Preserve nArr(k)
nArr(k) = sVal1
k = k + 1
Else
cFlag = False
End If
Next i
sVal1 = ""
For l = 0 To UBound(nArr)
sVal1 = sVal1 & nArr(l)
nArr(l) = ""
Next l
Label1.Caption = sVal1
End If
End Sub

: 条件=若字串阵列s(i)中含1234567890,.1/;'":@#$%^&*()_+|[]{}其中任一个
: 叙述=自s(i)中删除以上该字元
: 如:"string."---->string
: fat!gh ---->fatgh

: 不知该如何写??
: thanks

Follow Ups:

- Another solution wei 04:34:13 2/12/99 (0)