资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb.net取倍数 vb算数

VB.NET编写最小公倍数的代码是什么?

Dim m, n, r As Integer

创新互联建站主营涪陵网站建设的网络公司,主营网站建设方案,成都App定制开发,涪陵h5微信小程序搭建,涪陵网站营销推广欢迎涪陵等地区企业咨询

Dim gbs As Integer

Dim h As Integer

Dim k As Integer

Dim p As Integer

m = CInt(Me.TextBox1.Text)

n = CInt(Me.TextBox2.Text)

If m n Then

h = m

m = n

n = h

End If

k = m

p = n

r = m Mod n

Do While (r 0)

m = n

n = r

r = m Mod n

Loop

gbs = (p * k) / n

Me.TextBox4.Text = CStr(gbs)

Me.TextBox3.Text = CStr(n)

vb编程中找出100之内的3的倍数,显示时每行不超过6个?

只要让循环控制变量从3起步,每次的步长为3,每次输出一个数,当数满六个的时候就换行。

如何用vb做100以内2,3,5的倍数

窗体中创建三个check按钮,分别选中表示2的,3的,5的倍数

一个combo控件用于显示结果

Public m As Integer, n As Integer, k As Integer

Private Sub Check1_Click()

m = Check1.Value

n = Check2.Value

k = Check3.Value

Combo1.Clear

Call js(m, n, k)

End Sub

Private Sub Check2_Click()

m = Check1.Value

n = Check2.Value

k = Check3.Value

Combo1.Clear

Call js(m, n, k)

End Sub

Private Sub Check3_Click()

m = Check1.Value

n = Check2.Value

k = Check3.Value

Combo1.Clear

Call js(m, n, k)

End Sub

Sub js(mm As Integer, nn As Integer, kk As Integer)

Dim i As Integer

If mm = 1 Then

If nn + kk = 0 Then

Combo1.Text = "2的倍数"

For i = 1 To 100

If i Mod 2 = 0 Then Combo1.AddItem Str(i)

Next

ElseIf nn = 1 And kk = 0 Then

Combo1.Text = "2和3共同的倍数"

For i = 1 To 100

If i Mod 2 = 0 And i Mod 3 = 0 Then Combo1.AddItem Str(i)

Next

ElseIf nn = 0 And kk = 1 Then

Combo1.Text = "2和5共同的倍数"

For i = 1 To 100

If i Mod 2 = 0 Or i Mod 5 = 0 Then Combo1.AddItem Str(i)

Next

ElseIf nn = 1 And kk = 1 Then

Combo1.Text = "2,3,5的倍数"

For i = 1 To 100

If i Mod 2 = 0 And i Mod 3 = 0 And i Mod 5 = 0 Then Combo1.AddItem Str(i)

Next

End If

Else

If nn = 1 And kk = 0 Then

Combo1.Text = "3的倍数"

For i = 1 To 100

If i Mod 3 = 0 Then Combo1.AddItem Str(i)

Next

ElseIf nn = 0 And kk = 1 Then

Combo1.Text = "5的倍数"

For i = 1 To 100

If i Mod 5 = 0 Then Combo1.AddItem Str(i)

Next

ElseIf nn = 1 And kk = 1 Then

Combo1.Text = "3和5共同的倍数"

For i = 1 To 100

If i Mod 3 = 0 And i Mod 5 = 0 Then Combo1.AddItem Str(i)

Next

End If

End If

End Sub


网页名称:vb.net取倍数 vb算数
文章地址:http://cdkjz.cn/article/dojsged.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220