VB text1.text=text1.text+1
一个text1.text一个command1我在command1输入text1.text=text1.text+1点击一次text1内容加1.如果text1.text内容...
一个text1.text
一个command1
我在command1输入text1.text=text1.text+1点击一次text1内容加1.
如果text1.text内容是字母请问怎样加?比如之母是a,点一次command就变成b,直到z然后变成aa,ab 展开
一个command1
我在command1输入text1.text=text1.text+1点击一次text1内容加1.
如果text1.text内容是字母请问怎样加?比如之母是a,点一次command就变成b,直到z然后变成aa,ab 展开
展开全部
Private Sub Command1_Click()
Dim a As Integer, b As Integer
a = Asc(Right(Text1.Text, 1)) + 1
If Len(Text1.Text) > 1 Then
b = Asc(Mid(Text1.Text, Len(Text1.Text) - 1, 1))
Else
b = 96
End If
If a = 123 Then
a = 97
b = b + 1
End If
Text1.Text = ""
If b > 96 Then Text1.Text = Chr(b)
Text1.Text = Text1.Text & Chr(a)
End Sub
追问
这个加到zz的时候再加就变成了{a不知道怎么回事{b
追答
Private Sub Command1_Click()
Static a(9) As Integer
Dim i As Integer
If a(0) = 0 Then
For i = 0 To 9
a(i) = 96
Next
End If
For i = 0 To 9
a(i) = a(i) + 1
If a(i) < 123 Then Exit For
a(i) = 97
Next
Text1.Text = ""
For i = 0 To 9
If a(i) > 96 Then Text1.Text = Chr(a(i)) & Text1.Text
Next
End Sub
这个支持10位数,够用了吧?
追问
谢谢,但是问题出来了。一直加到z之后会变成符号,而不是变成aa,ab,ac这样的。请问怎样实现呢
追答
'【由于百度字数限制,注释省略,请参考图片】
Option Base 0
Function New_calc(ByVal NUM As String) As String
Dim singleNUM() As String
Dim i As Integer, flag As Boolean
ReDim singleNUM(Len(NUM) + 1)
NUM = LCase(NUM)
For i = 1 To Len(NUM)
singleNUM(i) = Mid(NUM, i, 1)
Next
flag = True
For i = Len(NUM) To 1 Step -1
If flag And singleNUM(i) = "z" Then
singleNUM(i) = "a"
flag = True
Else
singleNUM(i) = Chr(Asc(singleNUM(i)) + 1)
flag = False
Exit For
End If
Next
singleNUM(0) = ""
If flag Then singleNUM(0) = "a"
New_calc = ""
For i = 0 To Len(NUM)
New_calc = New_calc & singleNUM(i)
Next
End Function
Private Sub Command1_Click()
Text1.Text = New_calc(Text1.Text)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
试试这个
Private Sub Command1_Click()
Dim str As String
str = Text1.Text
Text1.Text = add(str)
End Sub
Function add(stradd As String)
Dim intR As Integer
Dim strR As String
Dim str As String
intR = Asc(Right(stradd, 1))
str = Mid(stradd, 1, Len(stradd) - 1)
If (intR > 47 And intR < 58) Then 'Êý×ÖµÄascll
intR = intR + 1
If (intR >= 58) Then
str = add(str)
intR = 48
End If
ElseIf (intR > 96 And intR < 123) Then 'Сд×Öĸ
intR = intR + 1
If (intR >= 123) Then
str = add(str)
intR = 97
End If
ElseIf (intR > 64 And intR < 91) Then '´óд
intR = intR + 1
If (intR >= 91) Then
str = add(str)
intR = 65
End If
Else
MsgBox "ÎÞЧ×Ö·û"
End
End If
add = str & Chr(intR)
End Function
Private Sub Command1_Click()
Dim str As String
str = Text1.Text
Text1.Text = add(str)
End Sub
Function add(stradd As String)
Dim intR As Integer
Dim strR As String
Dim str As String
intR = Asc(Right(stradd, 1))
str = Mid(stradd, 1, Len(stradd) - 1)
If (intR > 47 And intR < 58) Then 'Êý×ÖµÄascll
intR = intR + 1
If (intR >= 58) Then
str = add(str)
intR = 48
End If
ElseIf (intR > 96 And intR < 123) Then 'Сд×Öĸ
intR = intR + 1
If (intR >= 123) Then
str = add(str)
intR = 97
End If
ElseIf (intR > 64 And intR < 91) Then '´óд
intR = intR + 1
If (intR >= 91) Then
str = add(str)
intR = 65
End If
Else
MsgBox "ÎÞЧ×Ö·û"
End
End If
add = str & Chr(intR)
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询