VB基础代码.doc

上传人:11****ws 文档编号:2994600 上传时间:2019-05-16 格式:DOC 页数:3 大小:34KB
下载 相关 举报
VB基础代码.doc_第1页
第1页 / 共3页
VB基础代码.doc_第2页
第2页 / 共3页
VB基础代码.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、1、最大公约数 2、最小公倍数 Private Sub Command1_Click() Private Sub Command1_Click()Dim a As Long Dim a As LongDim b As Long Dim b As LongDim c As Long Dim c As Longa = Val(Text1.Text) Dim d As Longb = Val(Text2.Text) a = Val(Text1.Text)Do b = Val(Text2.Text)c = a Mod b x = aa = b y = bb = c DoLoop Until c = 0

2、 c = a Mod b Text3.Text = a a = bEnd Sub b = cPrivate Sub Command2_Click() Loop Until c = 0Text1.Text = “ d = a Text2.Text = “ Text3.Text = d * (x / d) * (y / d)Text3.Text = “ End Sub Text1.SetFocus Private Sub Command2_Click() 同 1 略 End Sub Private Sub Command3_Click() 同 1 略Private Sub Command3_Cli

3、ck()EndEnd Sub3、阶乘 4、因数Private Sub Command1_Click() Private Sub Command1_Click()Dim a As Long, i As Integer, s As Integer Dim x As Integer, k As Integera = Val(Text1.Text) Dim s As Strings = 1 k = 2i = 1 x = Val(Text1.Text)If a 0 Then Else: k = k + 1For i = 1 To a End Ifs = s * I Loop Until x = 1Nex

4、t i List1.AddItem Text1.Text &Text2.Text = s “=“ & Left(s, Len(s) - 1)End If End Sub5、质数 6、逆序Private Sub Command1_Click() Private Sub Command1_Click()Dim N As Long Dim s As String, a As StringN = Val(Text1.Text) Dim i As IntegerFor i = 2 To Sqr(N) s = Text1.TextIf N Mod i = 0 Then For i = 1 To Len(s)Text2.Text = “no“ a = Mid(s, i, 1) & aExit For Next iElse: Text2.Text = “yes“ Text2.Text = aEnd If End SubNextEnd SubPrivate Sub Command2_Click()同 1 略Private Sub Command3_Click()同 1 略

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 实用文档资料库 > 策划方案

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。