简单VB编程(来看看)

来源:百度知道 编辑:UC知道 时间:2024/05/10 12:41:40
4691261459
以上数据
转换成
1,2,4,5,6,9
或转成
124569
(注,转换后的数据为上面有的数字,且不重号,逗号隔开或不隔都可)
上面的数据不是固定的4691261459,也不只一行,
我将要输入LIST中然后通过转换按扭输到TEXT中。。
具体的写出来!

Private Function GetNumberString(strNumber As String) As String

Dim i As Integer
Dim j As Integer
Dim strResult
Dim count(1 To 9) As Integer
For i = 1 To 9
count(i) = 0
Next i
For i = 1 To Len(strNumber)

For j = 1 To Len(strNumber)
If Mid(strNumber, i, 1) = Mid(strNumber, j, 1) And count(CInt(Mid(strNumber, j, 1))) = 0 Then
strResult = strResult & Mid(strNumber, j, 1)
count(CInt(Mid(strNumber, j, 1))) = 1
End If
Next j
Next i
GetNumberString = strResult

End Function
我给你封装的函数,具有通用性,这个函数会把重复的数字去掉,只留下不重复的

对楼上改动一下
str1="046912061459"
str2=""
for i=0 to 9
if instr(str1,i) <>0 then
str2=str2 & i & " "
end if
next
Response.Write str2

str1="4691261459"
str2=""
for i=1 to 9
if replace(str1,