vb显示a(i) = Mid(Text1.Text, i, 1)下标越界,不知道错在哪里,求指教
PrivateSubCommand1_Click()ReDima(n)AsStringDimiAsByteReDimb(n)AsStringDimtAsStringn=L...
Private Sub Command1_Click()
ReDim a(n) As String
Dim i As Byte
ReDim b(n) As String
Dim t As String
n = Len(Text1.Text)
For i = 1 To n
a(i) = Mid(Text1.Text, i, 1)
b(i) = a(i)
Next i
For i = 1 To n / 2
t = a(i): a(i) = a(n - i + 1): a(n - i + 1) = t
Next i
For i = 1 To n
If a(i) <> b(i) Then Exit For
Next i
If i > n Then MsgBox ("是回文字符") Else MsgBox ("不是回文字符")
End Sub 展开
ReDim a(n) As String
Dim i As Byte
ReDim b(n) As String
Dim t As String
n = Len(Text1.Text)
For i = 1 To n
a(i) = Mid(Text1.Text, i, 1)
b(i) = a(i)
Next i
For i = 1 To n / 2
t = a(i): a(i) = a(n - i + 1): a(n - i + 1) = t
Next i
For i = 1 To n
If a(i) <> b(i) Then Exit For
Next i
If i > n Then MsgBox ("是回文字符") Else MsgBox ("不是回文字符")
End Sub 展开
3个回答
展开全部
Private Sub Command1_Click()
Dim n%
n = Len(Text1.Text)
ReDim a(1 To n) As String
Dim i As Byte
ReDim b(1 To n) As String
Dim t As String
For i = 1 To n
a(i) = Mid(Text1.Text, i, 1)
b(i) = a(i)
Next i
For i = 1 To n / 2
t = a(i): a(i) = a(n - i + 1): a(n - i + 1) = t
Next i
For i = 1 To n
If a(i) <> b(i) Then Exit For
Next i
If i > n Then MsgBox ("是回文字符") Else MsgBox ("不是回文字符")
End Sub
Dim n%
n = Len(Text1.Text)
ReDim a(1 To n) As String
Dim i As Byte
ReDim b(1 To n) As String
Dim t As String
For i = 1 To n
a(i) = Mid(Text1.Text, i, 1)
b(i) = a(i)
Next i
For i = 1 To n / 2
t = a(i): a(i) = a(n - i + 1): a(n - i + 1) = t
Next i
For i = 1 To n
If a(i) <> b(i) Then Exit For
Next i
If i > n Then MsgBox ("是回文字符") Else MsgBox ("不是回文字符")
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim i As Byte
Dim t As String
n = Len(Text1.Text)
ReDim a(n) As String
ReDim b(n) As String
For i = 1 To n
a(i) = Mid(Text1.Text, i, 1)
b(i) = a(i)
Next i
For i = 1 To n / 2
t = a(i): a(i) = a(n - i + 1): a(n - i + 1) = t
Next i
For i = 1 To n
If a(i) <> b(i) Then Exit For
Next i
If i > n Then MsgBox ("是回文字符") Else MsgBox ("不是回文字符")
End Sub
Dim i As Byte
Dim t As String
n = Len(Text1.Text)
ReDim a(n) As String
ReDim b(n) As String
For i = 1 To n
a(i) = Mid(Text1.Text, i, 1)
b(i) = a(i)
Next i
For i = 1 To n / 2
t = a(i): a(i) = a(n - i + 1): a(n - i + 1) = t
Next i
For i = 1 To n
If a(i) <> b(i) Then Exit For
Next i
If i > n Then MsgBox ("是回文字符") Else MsgBox ("不是回文字符")
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Vb默认数组下标为0
可以在通用中添加option base 1修改默认下标为1
可以在通用中添加option base 1修改默认下标为1
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询