编号按字母A-Z顺序递增,递增完一遍后号码自动升一位.
是否用可用数组来解决?
是否用可用数组来解决?
解决方案 »
- SSTab1中加入的button控件不見了
- WritePrivateProfileSection 是否有对应的 Kill 函數
- 数据库没有该记录删除时如何提示?
- LogonUser的用法。(XP domain上的用户都可以check,而win2K上WORKGROUP上的用户都认不到。。)
- 如何对汉字拼音格式化输出
- 窗体在任务栏图标的问题,谢谢解答
- XP式的下拉菜单!原理是什么呀
- sql语法的求救
- 用VB如何实现在excel里添加一行或者插入一行(一列),合并单元格等操作。我定义了一个对象可以访问EXCEL的表格,但是不知道怎么去实现以上操作。谢谢
- VB关于网络编程的问题
- 一道简单的VB题目,帮忙看看,谢谢
- 用ado操作excel偶尔出现灾难性故障,是怎么回事啊?
Dim TestCode As String
TestCode = "aa"
MsgBox GetNextCode(TestCode)
End SubPublic Function GetNextCode(str_Code As String) As String
Dim str_len As Integer
Dim tmp_len As Integer
Dim str_chr As String
str_len = Len(str_Code)
If (str_len = 0) Then '如果是空 则自动为 a
GetNextCode = "a"
Exit Function
End If
tmp_len = str_len
While (tmp_len)
str_chr = Mid(str_Code, tmp_len, 1) '从后边取一个字符
If str_chr < "z" Then '判断是否小z
str_chr = Chr(Asc(str_chr) + 1) '取下一个字符
GetNextCode = Left(str_Code, tmp_len - 1) + str_chr + Right(str_Code, str_len - tmp_len) '组合最后结果 既替换这个值
Exit Function
End If
tmp_len = tmp_len - 1
Wend
GetNextCode = str_Code + "a" '都是z的时候 在后边加a
End Function
Private Sub Command1_Click()
Dim x()
n = 100 '列数ReDim x(1 To n)
For i = 1 To n
k = Int((i - 1) / 26)
j = i - 26 * k
x(i) = IIf(k = 0, Chr(64 + j), Chr(64 + k) & Chr(64 + j))Print x(i), i
If i Mod 10 = 0 Then MsgBox "": Cls
NextEnd Sub
Dim tString As String
Dim tValue As Long
Text1.Text = ""
'tString = BitStringGetByValue(26, , 26)
'Text1.Text = Fix(1)
For tValue = 0 To 100
tString = BitStringGetByValue(tValue, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 26)
'tString = BitStringGetByValue(tValue, , 26)
Text1.Text = Text1.Text & tValue & "=" & tString & vbCrLf
Next
End SubPrivate Sub Form_Load()End Sub
Function BitStringGetByValue(ByVal pValue As Long, Optional ByVal pOutTableString As String = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", Optional ByVal pBound As Long = 10) As String
Dim tOutString As String
Dim tBytes() As Byte
tBytes() = BitBytesGetByValue(pValue, pOutTableString, pBound)
tOutString = StrConv(tBytes(), vbUnicode)
BitStringGetByValue = tOutString
End FunctionFunction BitBytesGetByValue(ByVal pValue As Long, Optional ByVal pOutTableString As String = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", Optional ByVal pBound As Long = 10) As Byte()
Dim tOutBytes() As Byte
Dim tOutBytes_Length As Long
Dim tBound_Log As Double
If CBool(pValue) Then
tBound_Log = Log(pValue) / Log(pBound)
tOutBytes_Length = Fix(tBound_Log)
Else
tOutBytes_Length = 0
End If
ReDim tOutBytes(tOutBytes_Length)
Dim tOutBytes_Index As Long
Dim tOutTable() As Byte
tOutTable() = StrConv(pOutTableString, vbFromUnicode)
Dim tBitValue As Long
For tOutBytes_Index = 0 To tOutBytes_Length
tBitValue = (pValue \ (pBound ^ tOutBytes_Index)) Mod pBound
tOutBytes(tOutBytes_Length - tOutBytes_Index) = tOutTable(tBitValue)
Next
BitBytesGetByValue = tOutBytes()
End Function