vb 查找字符
文本内容:safda"“"”“aaa代码如下:PrivateSubCommand2_Click()Dims,ss,k()AsStringDimiAsIntegerOpen...
文本内容:
safda
"“"
”“
a a a
代码如下:
Private Sub Command2_Click()
Dim s, ss, k() As String
Dim i As Integer
Open CommonDialog1.FileName For Input As #1
Do While Not EOF(1)
Line Input #1, s
k = Split(s, "")
For i = LBound(k) To UBound(k)
If k(i) = "a" Then
ss = ss + "zx"
End If
Next i
Loop
Close #1
Text2.Text = ss
End Sub
为什么text2.text不显示? 展开
safda
"“"
”“
a a a
代码如下:
Private Sub Command2_Click()
Dim s, ss, k() As String
Dim i As Integer
Open CommonDialog1.FileName For Input As #1
Do While Not EOF(1)
Line Input #1, s
k = Split(s, "")
For i = LBound(k) To UBound(k)
If k(i) = "a" Then
ss = ss + "zx"
End If
Next i
Loop
Close #1
Text2.Text = ss
End Sub
为什么text2.text不显示? 展开
2个回答
展开全部
因为没有满足的条件 k(i)="a" 所以text2显示空
solit(s," ") 要以空格为分界 而你没写 k = Split(s, " ")这样才对
Private Sub Command2_Click()
Dim s, ss, k() As String
Dim i As Integer
Open CommonDialog1.FileName For Input As #1
Do While Not EOF(1)
Line Input #1, s
k = Split(s, " ")
For i = LBound(k) To UBound(k)
If k(i) = "a" Then
ss = ss + "zx"
End If
Next i
Loop
Close #1
Text2.Text = ss
End Sub
solit(s," ") 要以空格为分界 而你没写 k = Split(s, " ")这样才对
Private Sub Command2_Click()
Dim s, ss, k() As String
Dim i As Integer
Open CommonDialog1.FileName For Input As #1
Do While Not EOF(1)
Line Input #1, s
k = Split(s, " ")
For i = LBound(k) To UBound(k)
If k(i) = "a" Then
ss = ss + "zx"
End If
Next i
Loop
Close #1
Text2.Text = ss
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询