下載本文檔
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、Option Explicit 6-1 Dim i As Integer Dim x As Integer Private Sub CmdExit_Click( End End Sub Private Sub CmdJudge_Click( x = Val(txtInput.Text For i = 2 To x / 2 If x Mod i = 0 Then Exit For Next If x Mod i <> 0 Then MsgBox Str(x & "是素?cái)?shù)!" Else MsgBox Str(x & "不是素?cái)?shù)!"
2、 End If End Sub 6-3 Option Explicit Private Sub CmdCalculate_Click( Dim x As Integer, n As Integer Dim s As Single, t As Single s = 1 x = Val(txtX.Text n = 1 Do n = n + 1 t = n * x / x n s = s + t If t < 10 -5 Then Exit Do Loop txtS = Str(s End Sub Private Sub CmdExit_Click( End End Sub 6-3改 Opti
3、on Explicit Private Sub CmdCalculate_Click( Dim x As Integer, n As Integer Dim s As Single, t As Single s = 1 x = Val(txtX.Text n = 1 Do n = n + 1 t = (n * x / x n * (-1 (n - 1 s = s + t If Abs(t < 10 -5 Then Exit Do Loop txtS = Str(s txtS = Format(txtS, "0.000000000" '0到1之間的小數(shù),例如0.
4、5,運(yùn)行時(shí)小數(shù)點(diǎn)前的0本不能顯示,用Format函數(shù)后能了 End Sub Private Sub CmdExit_Click( End End Sub 6-4 Dim n As Integer Private Sub CmdClear_Click( txtS.Text = "" txtV.Text = "" txtL.Text = "" txtS.SetFocus End Sub Private Sub CmdExit_Click( Unload Me End Sub Private Sub CmdInvert_Click( Dim
5、 i As Integer Dim s As String n = Len(txtS.Text For i = n To 1 Step -1 s = s + Mid(txtS.Text, i, 1 Next i txtV.Text = s End Sub Private Sub CmdLen_Click( n = Len(txtS.Text txtL.Text = n End Sub 7-10 Option Explicit Dim A(20 As Integer Private Sub CmdClear_Click( Text1 = "" List2.Clear End
6、Sub Private Sub CmdExit_Click( Unload Me End Sub Private Sub CmdForm_Click( Dim i As Integer, s As String For i = 1 To 20 A(i = Int(21 * Rnd + 20 s = s & A(i & " " If i = 10 Then s = s & Chr(13 & Chr(10 End If Next i Text1 = s End Sub Private Sub CmdTong_Click( Dim t As Int
7、eger Dim B(20 To 40 As Integer, i As Integer For i = 1 To 20 B(A(i = B(A(i + 1 Next i For i = 20 To 40 If B(i <> 0 Then List2.AddItem i & "出現(xiàn):" & B(i & "次" Next i End Sub 8-1 Option Explicit Dim sPhrase As String, sEncrypted As String Dim iLen As Integer Private
8、 Sub CmdOperate_Click(Index As Integer Dim sCurrent As String, sNew As String Dim sDecrypted As String Dim x As Integer If Index = 0 Then sPhrase = InputBox("請(qǐng)輸入短語(yǔ)", "短語(yǔ)將被加密" iLen = Len(sPhrase ElseIf Index = 1 Then sEncrypted = "" For x = 1 To iLen sCurrent = Mid(sPhra
9、se, x, 1 sNew = Chr(Asc(sCurrent + 2 sEncrypted = sEncrypted & sNew Next x MsgBox sEncrypted, vbExclamation, "加密的短語(yǔ)" ElseIf Index = 2 Then For x = 1 To iLen sCurrent = Mid(sEncrypted, x, 1 sNew = Chr(Asc(sCurrent - 2 sDecrypted = sDecrypted & sNew Next x MsgBox sDecrypted, vbExclam
10、ation, "解密的短語(yǔ)" Else Unload Me End If End Sub 9-4 Option Explicit Private Sub CmdClear_Click( Text1.Text = "" Text2.Text = "" Text3.Text = "" End Sub Private Sub CmdExit_Click( Unload Me End Sub Private Sub Option1_Click(Index As Integer Dim a As Integer, b As
11、Integer Dim m As Integer, d As Integer a = Text1 b = Text2 m = common(a, b If Index = 0 Then Text3 = m Else d = a * b / m Text3 = d End If End Sub Private Function common(ByVal a As Integer, ByVal b As Integer As Integer Dim r As Integer Do r = b Mod a If r = 0 Then Exit Do b = a a = r Loop While r
12、<> 0 common = a End Function 9-6 Option Explicit Private Sub CmdSearch_Click( Dim i As Integer For i = 3 To 100 Step 2 If prime(i And prime(i + 2 Then Print Str(i & "," & Str(i + 2 End If Next i End Sub Private Function prime(n As Integer As Boolean Dim i As Integer For i = 2
13、 To n - 1 If n Mod i = 0 Then prime = False Exit Function End If Next i prime = True End Function 9-7 Option Explicit Private Sub CmdClear_Click( Text1.Text = "" Text2.Text = "" Text3.Text = "" End Sub Private Sub CmdExit_Click( End End Sub Private Sub CmdTran_Click( Di
14、m s As Long Dim bin( As String Dim i As Integer, k As Integer For i = 1 To Len(Text2 k = k + 1 ReDim Preserve bin(k bin(k = Mid(Text2, i, 1 Next i Call tran(bin, s Text3 = s End Sub Private Sub Text1_Change( Dim n As Integer n = Val(Text1.Text Label3.Caption = Str$(n + "進(jìn)制數(shù)" End Sub Privat
15、e Sub tran(vary( As String, p As Long Dim i As Integer, n As Integer n = Val(Text1.Text For i = 1 To UBound(vary If Val(vary(i >= 0 And Val(vary(i <= 9 Then p = p + Val(vary(i * n (UBound(vary - i End If If Asc(UCase(vary(i >= 65 And Asc(UCase(Val(i <= 70 Then p = p + (Asc(UCase(vary(i -
16、 65 + 10 * n (UBound(vary - i End If Next i End Sub 10-4 Option Explicit Dim den As Integer, num As Integer Private Sub Command1_Click( lowterm num, den Text3.Text = CStr(den Text4.Text = CStr(num End Sub Private S ub Command2_Click( Text1.Text = "" Text2.Text = "" Text3.Text = &
17、quot;" Text4.Text = "" End Sub Private Sub Command3_Click( End End Sub Private Sub Text1_Change( den = Val(Text1.Text End Sub Private Sub Text2_Change( num = Val(Text2.Text End Sub Sub lowterm(x As Integer, y As Integer Dim gcdvalue As Integer gcdvalue = gcd(x, y If gcdvalue > 1 Th
18、en x = x / gcdvalue y = y / gcdvalue End If End Sub Private Function gcd(ByVal a1 As Integer, ByVal b1 As Integer Dim remainder As Integer remainder = a1 Mod b1 If remainder = 0 Then gcd = b1 Else a1 = b1 b1 = remainder gcd = gcd(a1, b1 End If End Function 10-8 Option Explicit Private Sub Command1_Click( Dim n As Integer, m As Integer For n = 10 To 9999 Call Armstrong(n Next n End Sub Private Sub Command2_Click
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 04年施工現(xiàn)場(chǎng)臨時(shí)設(shè)施建設(shè)與拆除合同
- 2024-2030年中國(guó)高頻無(wú)感電阻行業(yè)市場(chǎng)運(yùn)營(yíng)模式及未來(lái)發(fā)展動(dòng)向預(yù)測(cè)報(bào)告
- 2024年新倉(cāng)庫(kù)租賃協(xié)議:場(chǎng)地使用說(shuō)明
- 2024-2030年中國(guó)高端童裝行業(yè)營(yíng)銷模式及投資前景預(yù)測(cè)報(bào)告
- 2024-2030年中國(guó)高校后勤行業(yè)發(fā)展創(chuàng)新模式及投資前景展望報(bào)告
- 2024-2030年中國(guó)馬口鐵三片罐行業(yè)發(fā)展現(xiàn)狀及投資規(guī)模分析報(bào)告
- 2024-2030年中國(guó)陶瓷上絕緣板行業(yè)市場(chǎng)運(yùn)營(yíng)模式及未來(lái)發(fā)展動(dòng)向預(yù)測(cè)報(bào)告
- 2024年中、高檔黑白超聲診斷儀項(xiàng)目資金需求報(bào)告代可行性研究報(bào)告
- 2024年度建筑外觀設(shè)計(jì)咨詢合同
- 2024年新一代云計(jì)算服務(wù)合同
- 工程詢價(jià)合同模板
- 事業(yè)單位招聘《綜合基礎(chǔ)知識(shí)》考試試題及答案
- 無(wú)錫風(fēng)機(jī)吊裝施工方案
- 《突發(fā)事件應(yīng)急預(yù)案管理辦法》知識(shí)培訓(xùn)
- 江蘇省南京市建鄴區(qū)2024-2025學(xué)年九年級(jí)上學(xué)期期中考試物理試題(無(wú)答案)
- 中小學(xué)師德師風(fēng)建設(shè)各項(xiàng)制度匯編
- 2024年保安員證考試題庫(kù)及答案(共260題)
- 公務(wù)員2024年國(guó)考申論真題(地市級(jí))及參考答案
- XXXX酒店管理公司成立方案
- 民用無(wú)人機(jī)操控員執(zhí)照(CAAC)考試復(fù)習(xí)重點(diǎn)題及答案
- 疼痛科整體規(guī)劃和發(fā)展方案
評(píng)論
0/150
提交評(píng)論