vb 中print如何实现i 每五个数一行

vb 中print如何实现i 每五个数一行,第1张

Private
Sub
Command1_Click()
Cls
Dim
m%,
n%,
i%,
j%,
k%,
count%
m
=
Val(Text1Text)
n
=
Val(Text2Text)
If
m
<=
3
Or
n
<=
m
Then
MsgBox
"下限为大于等于3的整数并且要小于下限",
vbOKOnly,
"求给出范围的素数"
Else
For
i
=
m
To
n
For
j
=
2
To
i
-
1
If
i
Mod
j
=
0
Then
Exit
For
End
If
If
j
=
i
Then
'该条件永远不成立,需要修改
count
=
count
+
1
If
count
Mod
5
=
0
Then
Print
Else
Print
i;
End
If
End
If
Next
Next
End
If
End
Sub

#include<stdioh>
void main()
{
int num,i;
char buf[50];
printf("请输入数字:");
scanf("%d",&num);
sprintf(buf,"%d",num);
for(i=0;buf[i+1]!='\0';i++)
printf("%c,",buf[i]);
printf("%c",buf[i]);
}

冒泡,最简单。
Dim a As String
Dim arr(1 To 10) As Integer
Dim i, j, t As Integer
Private Sub Command1_Click()
For i = 1 To 10
a = InputBox("请输入第" & i & "个值")
arr(i) = Val(a)
Next i
For i = 1 To 9
For j = 1 To 9
If arr(j) > arr(j + 1) Then
t = arr(j + 1): arr(j + 1) = arr(j): arr(j) = t
End If
Next j
Next i
For i = 1 To 10
Print arr(i)
Next i
End Sub

Dim s As String, s1 As String, t() As String, t1() As String
Dim k1 As Integer, k2 As Integer, k3 As Integer
Open AppPath & "\123txt" For Input As #1
Open AppPath & "\组六txt" For Output As #2
Do Until EOF(1)
Line Input #1, s
If InStr(s, "组六包号") Then
t = Split(Replace(s, "组六包号", ""), ",")
For k1 = 0 To UBound(t) - 2
For k2 = 1 To UBound(t) - 1
For k3 = 2 To UBound(t)
If k1 <> k2 And k2 <> k3 And k1 <> k3 Then Print #2, t(k1) & t(k2) & t(k3)
Next
Next
Next
ElseIf InStr(s, "组六胆拖胆码:") Then
t = Split(Replace(s, "组六胆拖胆码:", ""), "拖码:")
t1 = Split(t(1), ",")
If InStr(t(0), ",") Then
For k1 = 0 To UBound(t1)
Print #1, Replace(t(0), ",", "") & t1(k1)
Next
Else
For k1 = 1 To UBound(t1) - 1
For k2 = 2 To UBound(t1)
If k1 <> k2 Then Print #2, t(0) & t1(k1) & t1(k2)
Next
Next
End If
ElseIf InStr(s, "组六和值") Then
t = Split(Replace(s, "组六和值", ""), ",")
For k1 = 0 To UBound(t)
For k2 = 0 To 999
s1 = Format(k2, "000")
If Val(Left(s1, 1)) + Val(Mid(s1, 2, 1)) + Val(Right(s1, 1)) = Val(t(k1)) And Val(Left(s1, 1)) < Val(Mid(s1, 2, 1)) And Val(Mid(s1, 2, 1)) < Val(Right(s1, 1)) Then Print #2, s1
Next
Next
End If
Loop
Close #2
Close #1

在该分行的下一行写 print即可。
如 print a(i);
print
print b(i);
中间的 print 就起到了分行的作用

简单啊。建立个窗体,在上面放一个按钮,然后把下面这段代码写到按钮的click事件中,运行程序,点一下按钮就会出来一行随机数。
Private
Sub
Command1_Click()
For
i
=
1
To
10
x
=
Int(Rnd()

10)
Print
x;
Next
i
Print
End
Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/10378034.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-08
下一篇 2023-05-08

发表评论

登录后才能评论

评论列表(0条)

保存