vb6,0问题 Private Sub Command1_Click() x = 5 For i = 1 To 20 Step 2 x = x + i \ 5 Next i Print x En

 我来答
司涵桃
2011-03-07 · TA获得超过419个赞
知道小有建树答主
回答量:559
采纳率:0%
帮助的人:126万
展开全部
的值是奇数,并返回相应的数字串
Private Function IsOddNumber(ByVal pString As String, ByRef pStrNum) As Boolean
Dim x As Long
Dim Num As Long

If Len(Trim(pString)) = 0 Then Exit Function
x = InStr(pString, "(")
If x = 0 Then '没有括号,视出现1次
pStrNum = pString
Num = 1
Else
pStrNum = Mid(pString, 1, x - 1)
Num = Val(Mid(pString, x + 1))
End If
IsOddNumber = (Num And 1)
End Function
'数字串计数函数
Private Sub GetNumCount(pStrNum As String, NumCount() As Long, pMaxNum)
Dim n As Long
Do
n = Mid(pStrNum, 1, 1)
NumCount(n) = NumCount(n) + 1
If NumCount(n) > pMaxNum Then pMaxNum = NumCount(n)
Mid(pStrNum, 1, 1) = Chr(32)
pStrNum = Trim(pStrNum)
Loop While Len(pStrNum)
End Sub

Private Sub Command1_Click()

Dim NumCount(9) As Long
Dim arr() As String
Dim i As Long
Dim strTmp As String
Dim lngTmp As Long
Dim maxNum As Long
Dim x As Long
Dim tmp() As String

arr = Split(Text1, vbCrLf)
For i = 0 To UBound(arr)
If Len(arr(i)) > 0 Then
tmp = Split(arr(i), ",")
For x = 0 To UBound(tmp)
If IsOddNumber(tmp(x), strTmp) Then
Call GetNumCount(strTmp, NumCount, maxNum)
End If
Next
End If
Next

'归类排序相同次数值
ReDim tmp(maxNum)
For i = 0 To 9
tmp(NumCount(i)) = tmp(NumCount(i)) & i
Next

'组合排序结果
ReDim arr(9)
x = 0
For i = maxNum To 0 Step -1
If Len(tmp(i)) > 0 Then
arr(x) = tmp(i) & "(" & i & ")"
x = x + 1
End If
Next
ReDim Preserve arr(x - 1)
'MsgBox Join(arr, ",")

'写入txt文本
Dim hFile As Long
Dim pFile As String

pFile = App.Path & "\myTxt.txt"
hFile = FreeFile
Open pFile For Output As hFile
Print #hFile, Join(arr, ",")
Close
'打开文本
Shell "NOTEPAD.EXE " & pFile, vbNormalNoFocus

End Sub

Private Sub Form_Load()
Dim s As String
s = "2(13),6(12),1(11),8(6),0479(5),3(4),5(3)" & vbCrLf
s = s & "3(15),5(10),278(1),0149(0)" & vbCrLf
s = s & "13(4),057" & vbCrLf
s = s & "13456(2),027(1)" & vbCrLf
Text1 = s
End Sub
sxzsd123
2011-03-06 · 超过30用户采纳过TA的回答
知道答主
回答量:139
采纳率:0%
帮助的人:74.8万
展开全部
Private Sub Command1_Click()
dim x = 5
For i = 1 To 20 Step 2
x = x + i \ 5
Print x
Next i
End Sub
是实现这个功能还是实现下面这个功能
Private Sub Command1_Click()
dim x = 5
For i = 1 To 20 Step 2
x = (x + i) \ 5
Print x
Next i
End Sub
问题没说清楚
追问
Print x 
答案是21,我不懂、、、
追答
把整个题目发出来才能弄清楚
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式