txtSQL = "select count(*) as id from gsinfo" Set mrc = ExecuteSQL(txtSQL, MsgText) qyno1 = mrc.Fields("id").Value MsgBox qyno1, vbOKOnly + vbExclamation, "提示!" 'qyno2= 'For qyno1 = qyno1 To 9999 'qyno1 = qyno1 + 1 If qyno1 < 10 Then qyno1 = "000" & qyno1 ElseIf qyno1 > 10 And qyno1 <= 99 Then qyno1 = "00" & qyno1 ElseIf qyno1 > 99 Then qyno1 = "0" & qyno1 End If 'Next qyno1 MsgBox qyno1, vbOKOnly + vbExclamation, "提示!"我这样写 为什么没有再我的qyno1前面加上我想要的0
dim qynol as string If cint(qyno1) < 10 Then qyno1 = "000" & qyno1 ElseIf cint(qyno1) > 10 And cint(qyno1) <= 99 Then qyno1 = "00" & qyno1 ElseIf cint(qyno1) > 99 Then qyno1 = "0" & qyno1 End If获得使用两个变量,一个字符串,一个整型
Private Sub Form_Load() MsgBox LongToString(1, 5) End SubPublic Function LongToString(ByVal lngInput As Long, ByVal intLength As Integer) As String Dim strRet As String Dim i As Integer
If Len(CStr(lngInput)) >= intLength Then strRet = CStr(lngInput) Else strRet = String(intLength - Len(CStr(lngInput)), "0") & CStr(lngInput) End If
LongToString = strRet End Function
上面这个函数中的变量可以省略: Private Sub Form_Load() MsgBox LongToString(1, 4) End SubPublic Function LongToString(ByVal lngInput As Long, ByVal intLength As Integer) As String If Len(CStr(lngInput)) >= intLength Then LongToString = CStr(lngInput) Else LongToString = String(intLength - Len(CStr(lngInput)), "0") & CStr(lngInput) End If End Function
取出来转化成 cint 加一 在 FORMAT成 5位字符串
Set mrc = ExecuteSQL(txtSQL, MsgText)
qyno1 = mrc.Fields("id").Value
MsgBox qyno1, vbOKOnly + vbExclamation, "提示!"
'qyno2=
'For qyno1 = qyno1 To 9999
'qyno1 = qyno1 + 1
If qyno1 < 10 Then
qyno1 = "000" & qyno1
ElseIf qyno1 > 10 And qyno1 <= 99 Then
qyno1 = "00" & qyno1
ElseIf qyno1 > 99 Then
qyno1 = "0" & qyno1
End If
'Next qyno1
MsgBox qyno1, vbOKOnly + vbExclamation, "提示!"我这样写
为什么没有再我的qyno1前面加上我想要的0
If cint(qyno1) < 10 Then
qyno1 = "000" & qyno1
ElseIf cint(qyno1) > 10 And cint(qyno1) <= 99 Then
qyno1 = "00" & qyno1
ElseIf cint(qyno1) > 99 Then
qyno1 = "0" & qyno1
End If获得使用两个变量,一个字符串,一个整型
MsgBox LongToString(1, 5)
End SubPublic Function LongToString(ByVal lngInput As Long, ByVal intLength As Integer) As String
Dim strRet As String
Dim i As Integer
If Len(CStr(lngInput)) >= intLength Then
strRet = CStr(lngInput)
Else
strRet = String(intLength - Len(CStr(lngInput)), "0") & CStr(lngInput)
End If
LongToString = strRet
End Function
Private Sub Form_Load()
MsgBox LongToString(1, 4)
End SubPublic Function LongToString(ByVal lngInput As Long, ByVal intLength As Integer) As String
If Len(CStr(lngInput)) >= intLength Then
LongToString = CStr(lngInput)
Else
LongToString = String(intLength - Len(CStr(lngInput)), "0") & CStr(lngInput)
End If
End Function