譬如666666 就是只有一个数字
656665 只有2个数字
怎么判断这种?
656665 只有2个数字
怎么判断这种?
解决方案 »
- 如何清除API的SetPixel函数画的线
- 问一个关于Double 普通算术问题
- 在XP系统下用VB打包的程序在2003下不能安装
- 我打包的程序出现“运行时错误76”,未找到路径??
- ado 控件datagrid 删除记录问题
- 查询数据时,想做一个进度条,不知如何获取当前查询的进度?
- 如果我在程序中只用到data控件,那么...
- 在vb中.如果打开一个记录.如果设定一个数据,如比这个数据少的话,就提示出来.应该怎么做啊
- 怎么获取vb程序自身所有窗体的caption?窗体的个数和名称不固定的情况下
- 我有一个DBcmobo,我想清除它的下拉列表里所有内容,我该怎么办?
- listview个滚动条问题!!
- 代码共享兼散分:很久前写的模糊聚类算法(FCM)和硬聚类算法,对于数据分析和图像分割等等方面都大有帮助,望大家赏脸。
Dim n As Long
n = 6666
If n / CLng(String(Len(CStr(n)), Left(CStr(n), 1))) = 1 Then
MsgBox "是单一数字"
Else
MsgBox "不是单一数字"
End If
End Sub
Dim s As String
Dim a(0 To 9) As Long
Dim b() As Integer
Dim i As Long
Dim j As Long
s = "656656"
If IsNumeric(s) = False Then Exit Sub
ReDim b(0 To Len(s) - 1) As Integer
CopyMemory b(0), ByVal StrPtr(s), LenB(s)
ZeroMemory a(0), UBound(a)
For i = 0 To UBound(b)
b(i) = b(i) - 48
a(b(i)) = a(b(i)) + 1
Next
j = UBound(a) + 1
For i = 0 To UBound(a)
If a(i) = 0 Then j = j - 1
Next
MsgBox j
End Sub
Hassle的算法挺好的,计数算法吧。不过不明白ZeroMemory有什么用,似乎没了那句一样能用。
仿照Hassle的自己写了一个,效率比他的慢3倍以上。
Private Sub Command1_Click()
Dim i As Long
Dim j As Long
Dim a(0 To 9) As Long
Dim b() As Integer
Dim sngTime As Single
Dim sngTime1 As Single
sngTime = Timer
For j = 0 To 10000
ReDim b(0 To Len(strShuZi) - 1) As Integer
For i = 1 To UBound(b) + 1
b(i - 1) = CInt(Mid(strShuZi, i, 1))
a(b(i - 1)) = a(b(i - 1)) + 1
Next
Next
j = UBound(a) + 1
For i = 0 To UBound(a)
If a(i) = 0 Then j = j - 1
Next
sngTime1 = Timer
Text1 = Text1 & "VB我的:" & CStr(j) & "," & CStr(sngTime1 - sngTime) & vbCrLf
End Sub