vb 如何让结果显示在label中
PrivateSubCommand1_Click()m=Val(text1.Text):n=Val(text2.Text)Ifm<1Thenm=2Fori=mTons=1...
Private Sub Command1_Click()
m = Val(text1.Text): n = Val(text2.Text)
If m < 1 Then m = 2
For i = m To n
s = 1: t = 0
For j = 2 To i \ 2
If i Mod j = 0 Then s = s + j
Next j
If s = i Then
Print i; "的因子是1";
For j = 2 To i \ 2
If i Mod j = 0 Then
Print ","; j;
t = t + 1
If t Mod 6 = 0 Then Print: Print " ";
End If
Next j
Print
End If
Next i
End Sub 展开
m = Val(text1.Text): n = Val(text2.Text)
If m < 1 Then m = 2
For i = m To n
s = 1: t = 0
For j = 2 To i \ 2
If i Mod j = 0 Then s = s + j
Next j
If s = i Then
Print i; "的因子是1";
For j = 2 To i \ 2
If i Mod j = 0 Then
Print ","; j;
t = t + 1
If t Mod 6 = 0 Then Print: Print " ";
End If
Next j
End If
Next i
End Sub 展开
4个回答
2015-07-08
展开全部
可以用Label1.caption = RS.fields("字段名")来实现;
参考代码如下:
Private Sub Command1_Click()
Dim Cnn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Cnn.ConnectionString = "Provider=SQLOLEDB;Data Source=john;UID=sa;PWD=123;initial catalog=aaa"
Cnn.Open
Rs.Open "select A from aaa", Cnn
Label1.caption = RS.getstring
参考代码如下:
Private Sub Command1_Click()
Dim Cnn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Cnn.ConnectionString = "Provider=SQLOLEDB;Data Source=john;UID=sa;PWD=123;initial catalog=aaa"
Cnn.Open
Rs.Open "select A from aaa", Cnn
Label1.caption = RS.getstring
展开全部
Private Sub Command1_Click()
m = Val(text1.Text): n = Val(text2.Text)
Label1.Caption = ""
If m < 1 Then m = 1
For i = m To n
s = 1: t = 0
For j = 2 To i \ 2
If i Mod j = 0 Then s = s + j
Next j
If s = i Then
Label1.Caption = Label1.Caption & i & "的因子是1"
For j = 2 To i \ 2
If i Mod j = 0 Then Label1.Caption = Label1.Caption & "," & j
Next j
Label1.Caption = Label1.Caption & vbCrLf
End If
Next i
End Sub
记得标签的高度要做得稍大一点哦,不然的话多行就无法显示啦!
m = Val(text1.Text): n = Val(text2.Text)
Label1.Caption = ""
If m < 1 Then m = 1
For i = m To n
s = 1: t = 0
For j = 2 To i \ 2
If i Mod j = 0 Then s = s + j
Next j
If s = i Then
Label1.Caption = Label1.Caption & i & "的因子是1"
For j = 2 To i \ 2
If i Mod j = 0 Then Label1.Caption = Label1.Caption & "," & j
Next j
Label1.Caption = Label1.Caption & vbCrLf
End If
Next i
End Sub
记得标签的高度要做得稍大一点哦,不然的话多行就无法显示啦!
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
label1.caption=你要显示的内容
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
label1.caption=m
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询