您好,欢迎来到意榕旅游网。
搜索
您的当前位置:首页VB上机程序设计题 参考题解(!)

VB上机程序设计题 参考题解(!)

来源:意榕旅游网
 第五部分:上机程序设计题题解

1. 加法器

Private Sub Form_Load() Text1.Alignment = 1 Text2.Alignment = 1 Text3.Alignment = 1 Text3.Enabled=False End Sub

Private Sub Command1_Click()

Text3.Text = Str(Val(Text1.Text) + Val(Text2.Text)) End Sub

Private Sub Command2_Click() Text1.Text = \"\" Text2.Text = \"\" Text3.Text = \"\" Text1.SetFocus End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0 Text1.Text = \"\" End If End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)

If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0 : Text2.Text = \"\" End If End Sub 2. 健康称 Private Sub Command1_Click()

Dim sg As Single, tz As Single, bz As Single sg = Val(Text1.Text) : tz = Val(Text2.Text) bz = sg - 105

If tz >= 1.1 * bz Then

Label5.Caption = \"偏胖,注意节俭!\" ElseIf tz <= 0.9 * bz Then

Label5.Caption = \"偏瘦,增加营养!\" Else

Label5.Caption = \"正常。继续保持!\" End If End Sub

Private Sub Form_Load() Form1.Caption = \"健康称\"

Text1.Alignment = 1 „右对齐 Text2.Alignment = 1

Text1.MaxLength = 3 „最大长度为3 Text2.MaxLength = 3 End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)

If KeyAscii < 48 Or KeyAscii > 58 Then KeyAscii = 0: Text1.SetFocus End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)

1

If KeyAscii < 48 Or KeyAscii > 58 Then KeyAscii = 0: Text2.SetFocus End Sub 3. 最大化 Private Sub Command1_Click()

If Command1.Caption = \"最大化(&L)\" Then

Form1.WindowState = 2 : Command1.Caption = \"还原(&B)\" Else

Form1.WindowState = 0 : Command1.Caption = \"最大化(&L)\" End If End Sub

Private Sub Form_Resize()

Command1.Left = (Form1.ScaleWidth - Command1.Width) / 2 Command1.Top = (Form1.ScaleHeight - Command1.Height) / 2 End Sub 4. 判断质数 Private Sub Command1_Click() Dim I As Integer, X As Integer X = Val(Text1)

For I = 2 To sqr(X)

If X Mod I = 0 Then Exit For Next

If I > sqr(X) Then

Label3.Caption = \"是质数\" Else

Label3.Caption = \"不是质数\" End if End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0

MsgBox \"输入的不是数字,无法计算\" End If End Sub 5. 计算平均成绩 Private Sub Form_Load() Text2.Enabled = False End Sub

Private Sub Text1_Change(Index As Integer) Text2 = \"\"

Text2 = (Val(Text1(0)) + Val(Text1(1)) + Val(Text1(2))) / 3 End Sub

Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer) If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0 beep End If End Sub 6. 收款计算 Private Sub Form_Load() Text3.Enabled = False End Sub

Private Sub Command1_Click() '清除 Text1 = \"\"

2

Text2 = \"\" Text3 = \"\"

Text1.SetFocus End Sub

Private Sub Command2_Click() '计算 Text3 = Val(Text1) * Val(Text2) End Sub 7. 编辑 Dim s as string

Private Sub Command1_Click() '复制 s=Text1.SelText End Sub

Private Sub Command2_Click() '剪切 s= Text1.SelText Text1.SelText = \"\" End Sub

Private Sub Command3_Click() '粘贴 Text1.SelText = s End Sub

Private Sub Command4_Click() Text1.SelText = \"\" End Sub 8. 密码检验 Dim i as Integer „i用来统计输入密码的次数 Private Sub Form_Load() „以下属性都可以在属性窗口中设置 Text1.MaxLength = 7 Text1.PasswordChar = \"*\" Label2.Alignment = 2 Label2.ForeColor = vbRed Label2.FontName = \"宋体\" Label2.FontSize = 20 Label2.AutoSize = True Label2.Visible = False End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Label2.Visible=True

If Text1.Text = \"1234567\" Then

Label2.Caption = \"欢迎光临!\" : i=0

Else i=i+1

If i = 1 Then

Label2.Caption = \" 密码不符,请再输一遍!\" Text1.Text = \"\" Else

Label2.Caption = \" 非法用户,请退出程序!\" Text1.Text = \"\" : Text1.Enabled = False End If End If End If End Sub

3

9. 密码修改

Private Sub Command1_Click()

If Text1.Text = Text2.Text And Text1.Text = \"admin\" Then If Text3.Text = Text4.Text Then MsgBox \"密码修改成功\" End Else

MsgBox \"两次新密码输入不一致,请重输\" Text3.Text = \"\" Text4.Text = \"\" Text3.SetFocus End If Else

MsgBox \"用户出错,请重新输入\" Text1.Text = \"\" Text2.Text = \"\" Text1.SetFocus End If End Sub

Private Sub Command2_Click() End End Sub 10. 字符排序 Private Sub Command1_Click()

Dim x As String '原始字符串

Dim y As String '重新组合的字符串 Dim a() As String '拆分出来的字符数组 Dim n As Integer '字符串长度

Dim i As Integer, j As Integer, t As String, p as integer

x = Text1.Text n = Len(x)

ReDim a(n) As String

For i = 1 To n '字符串拆分 a(i) = Mid(x, i, 1) Next i

For i = 1 To n - 1 '字符排序 p=i

For j = i + 1 To n

If a(j) < a(p) Then p=j Next j

t = a(i): a(i) = a(p): a(p) = t Next i

y = \"\" '排序后的字符组成新字符串 For i = 1 To n Print a(i); Next i End Sub

Private Sub Command2_Click() End End Sub 11. 替换 Private Sub command1_Click() Dim x As Integer

x = InStr(text1.text, text2.text‘x为在Text1中,text2第一次出现的位置

4

If x = 0 Then

MsgBox \"没找到\"

Else

Do While x <> 0

Text1.SelStart = x - 1

Text1.SelLength = Len(Text2.text) Text1.SelText = Text3.Text x = InStr(Text1.text, Text2.text)

Loop

End if End Sub 12. 显示星期年月 Private Sub Option1_Click() '显示星期几

Text1.text = “今天是星期” & WeekdayName(Weekday(Date)) End Sub

Private Sub Option2_Click() '显示年份

Text1.text =”今天是” & Year(Date) & “年” End Sub

Private Sub Option3_Click() '显示月份

Text1.text = ”今天是” & Month(Date) & “月” End Sub

Private Sub Option4_Click() '显示日期

Text1.text =”今天是” & Day(Date) & “号” End Sub

Private Sub Command1_Click() '结束 End End Sub 13. 点餐 Private Sub Check1_Click(Index As Integer) If Check1(Index).Value = 1 Then Text1(Index).Enabled = True Else

Text1(Index).Enabled = False Text1(Index).Text = \"\" End If End Sub

Private Sub Command1_Click() Dim s As Long

If Check1(0).Value = 1 Then s = s + Val(Text1(0).Text) * 18 If Check1(1).Value = 1 Then s = s + Val(Text1(1).Text) * 23 If Check1(2).Value = 1 Then s = s + Val(Text1(2).Text) * 28 MsgBox \"一共\" & s & \"元\" End Sub

Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer) If (KeyAscii < 47 Or KeyAscii > 58) And KeyAscii <> 8 Then KeyAscii = 0 End If End Sub 14. 字体修饰 Private Sub Check1_Click() If Check1.Value = 1 Then Label1.FontBold = True Else

5

Label1.FontBold = False End If End Sub

Private Sub Check2_Click() If Check2.Value = 1 Then Label1.FontItalic = True Else

Label1.FontItalic = False End If End Sub

Private Sub Option1_Click() Label1.FontName = \"宋体\" End Sub

Private Sub Option2_Click()

Label1.FontName = \"楷体_gb2312\" End Sub 15. 输出选择的信息 Private Sub Form_Load() Combo1.AddItem \"Intel\" Combo1.AddItem \"Dell\" Combo1.Text = \"联想\" End Sub

Private Sub Check1_Click() If Check1.Value = 1 Then Combo1.Enabled = True Text1.Enabled = True Else

Combo1.Enabled = False Text1.Enabled = False End If End Sub

Private Sub Check2_Click() If Check2.Value = 1 Then Option1.Enabled = True Option2.Enabled = True Else

Option1.Enabled = False Option2.Enabled = False End If End Sub

Private Sub Command1_Click() Label3.Caption = \"\"

If Check1.Value = 1 Then

Label3.Caption = Combo1.Text & Text1.Text End If

If Check2.Value = 1 Then

If Option1.Value = True Then

Label3.Caption = Label3.Caption & Option1.Caption ElseIf Option2.Value = True Then

Label3.Caption = Label3.Caption & Option2.Caption End If End If End Sub

6

16. 改变字号 Private Sub Form_Load() HScroll1.Max = 72 HScroll1.Min = 8

Label1.FontSize = HScroll1.Value Text1.MaxLength=2 End Sub

Private Sub HScroll1_Change() Text1.Text = HScroll1.Value

Label1.FontSize = HScroll1.Value End Sub

Private Sub HScroll1_Scroll()

Text1.Text = HScroll1.Value Label1.FontSize = HScroll1.Value End Sub

Private Sub Text1_Change()

If Len(Text1.Text) = 2 Then „如果文本框里输入了两位字号

HScroll1.Value = Text1.Text „修改滑块位置和标签字体 Label1.FontSize = Text1.Text End If End Sub 17. 标签移动 Private Sub Form_Load()

HScroll1.Value = Label1.Left HScroll1.Min = HScroll1.Left

HScroll1.Max = HScroll1.Left + HScroll1.Width - Label1.Width HScroll1.SmallChange = 50 : HScroll1.LargeChange = 100 End Sub

Private Sub HScroll1_Change() Label1.Left = HScroll1.Value End Sub

Private Sub HScroll1_Scroll() Label1.Left = HScroll1.Value End Sub

Private Sub Command1_Click() '结束 End End Sub 18. 调色板 Private Sub Form_Load() HScroll1(0).Max=255 HScroll1(1).Max=255 HScroll1(2).Max=255 Shape1.FillStyle=0 End Sub

Private Sub Command1_Click()

Label2.ForeColor =Shape1.FillColor End Sub

Private Sub HScroll1_Change(Index As Integer) Dim r As Integer, g As Integer, b As Integer r = HScroll1(0).Value g =HScroll1(1).Value b = HScroll1(2).Value

Shape1.FillColor = RGB(r , g , b)

7

End Sub

Private Sub HScroll1_Scroll(Index As Integer) Call HScroll1_Change(Index) End Sub

19. 字体设置

Private Sub Form_Load() Combo1.AddItem \"宋体\" Combo1.AddItem \"黑体\"

Combo1.AddItem \"楷体_Gb2312\" Combo2. AddItem “8” Combo2. AddItem “9” Combo2. AddItem “10” Combo2. AddItem “11” Combo2. AddItem “12” Combo2. AddItem “14” Combo2. AddItem “16” Combo2. AddItem “18”

„其余字号自己根据程序效果进行添加 End Sub

Private Sub Combo1_Click()

Text1.FontName = Combo1.Text End Sub

Private Sub Combo2_Click() Text1.FontSize = Combo2.Text End Sub 20. 格式设置 Private Sub Combo1_click() Select Case Combo1.Text Case \"左对齐\"

Text1.Alignment = 0 Case \"居中\"

Text1.Alignment = 2 Case \"右对齐\"

Text1.Alignment = 1 End Select End Sub

Private Sub Combo2_click() Select Case Combo2.Text Case \"常规\"

Text1.FontBold = False Text1.FontItalic = False Case \"斜体\"

Text1.FontBold = False Text1.FontItalic = True Case \"粗体\"

Text1.FontBold = True Text1.FontItalic = False Case \"粗斜体\"

Text1.FontBold = True Text1.FontItalic = True End Select End Sub 21. 添加与删除 Private Sub Command1_Click()

8

If Text1.Text = \"\" Then

MsgBox \"没有内容,不予添加!\" Text1.SetFocus Else

List1.AddItem Text1.Text, 0 Text1.Text = \"\" Text1.SetFocus End If End Sub

Private Sub Command2_Click() If List1.ListIndex = -1 Then

MsgBox \"请选择输出的项目\" Else

List1.RemoveItem List1.ListIndex End If End Sub 22. 偶数迁移 Private Sub Command1_Click() Dim x As Integer, i As Integer List1.Clear Randomize For i = 1 To 10

x = Int(Rnd * 90) + 10 List1.AddItem x Next i End Sub

Private Sub Command2_Click() Dim i As Integer List2.Clear

Do While i <= List1.ListCount - 1 If List1.List(i) Mod 2 = 0 Then List2.AddItem List1.List(i) List1.RemoveItem i Else

i = i + 1 End If Loop End Sub 23. 列表框间移动 Private Sub Form_Load() List1.AddItem \"111\" List1.AddItem \"222\" List2.AddItem \"333\" List2.AddItem \"444\" End Sub

Private Sub Command1_Click() '> If List1.ListIndex <> -1 Then List2.AddItem List1.Text

List1.RemoveItem List1.ListIndex Else

MsgBox \"先选择,再移动\" End If End Sub

Private Sub Command2_Click() '>>

9

Dim i As Integer

For i = 0 To List1.ListCount - 1 List2.AddItem List1.List(i) Next i List1.Clear End Sub

Private Sub Command3_Click() '< If List2.ListIndex <> -1 Then List1.AddItem List2.Text

List2.RemoveItem List2.ListIndex Else

MsgBox \"先选择,再移动\" End If End Sub

Private Sub Command4_Click() '<< Dim i As Integer

For i = 0 To List2.ListCount - 1 List1.AddItem List2.List(i) Next i List2.Clear End Sub

Private Sub Command5_Click() '结束 End End Sub 24. 添加信息 Private Sub Combo1_Click(Index As Integer) Dim i%

n = Combo1(0).ListIndex For i = 0 To 3

Text1(i).Text = Combo1(i).List(n) Next i End Sub

Private Sub Command1_Click() Dim i%

If Text1(0).Text = \"\" Then MsgBox \"请输入内容!\" Else

For i = 0 To 3

Combo1(i).AddItem Text1(i).Text Next i End If

For i = 0 To 3 Text1(i).Text = \"\" Next i End Sub

Private Sub Command2_Click() Dim i%

If Combo1(0).ListIndex = -1 Then MsgBox \"请选择删除的项目\" Else

For i = 0 To 3

Combo1(i).RemoveItem ListIndex Combo1(i).Text = \"\" Text1(i).Text = \"\" Next i

10

End If End Sub

Private Sub Form_Load() Dim i%

For i = 0 To 3

Combo1(i).Text = \"\" Next i

For i = 1 To 3

Combo1(i).Visible = False Next i End Sub

25. 电子钟

Private Sub Form_Load() Timer1.Interval = 1000 Timer2.Interval = 500

Form1.Caption = \"电子钟\" Timer2.Enabled = False End Sub

Private Sub Timer1_Timer() Label1.Caption = Time End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then

Timer2.Enabled = True End If End Sub

Private Sub Timer2_Timer()

If Text1.Text <= Label1.Caption Then If Label1.BackColor=vbRed Then Label1.BackColor = vbWhite Else

Label1.BackColor = vbRed End If End If End Sub 26. 倒计时 Dim t As Integer „t 表示总时间 Private Sub Command1_Click()

If Option1(0).Value = True Then t = 5 If Option1(1).Value = True Then t = 60 * 5 If Option1(2).Value = True Then t = 60 * 10 Timer1.Enabled = True Frame1.Enabled = False Command1.Enabled = False End Sub

Private Sub Timer1_Timer()

Dim m as integer, s as integer t = t - 1

If t = 0 Then

Label1.Caption = \"时间到\" Timer1.Enabled = False Frame1.Enabled = True Command1.Enabled = True Else

11

m = t \\ 60 s = t Mod 60

Label1.Caption = m & \"分\" & s & \"秒\" End If End Sub 27. 字幕闪烁 Private Sub Form_Load()

Label1.Caption = \"祝您考试成功\" Timer1.Interval = 300 Label1.Alignment = 1 Timer1.Enabled = False End Sub

Private Sub Command1_Click()

If Command1.Caption = \"开始\" Then Timer1.Enabled = True

Command1.Caption = \"停止\" Else

Command1.Caption = \"开始\" Timer1.Enabled = False End If End Sub

Private Sub Timer1_Timer()

If Label1.ForeColor = vbRed Then Label1.ForeColor = vbBlue Else

Label1.ForeColor = vbRed End If End Sub

28. 字幕滚动

Private Sub Form_Load()

Form1.Caption = \"字幕滚动\" Timer1.Interval = 100 Timer1.Enabled = False

Label1.Caption = \"祝您考试成功!\" Label1.ForeColor = vbRed End Sub

Private Sub Command1_Click()

If Command1.Caption = \"开始\" Then

Timer1.Enabled = True: Command1.Caption = \"停止\" Else

Timer1.Enabled = False

Command1.Caption = \"开始\" End If End Sub

Private Sub Timer1_Timer()

Label1.Left = Label1.Left + 100

If Label1.Left >= Form1.ScaleWidth Then Label1.Left = -Label1.Width End If End Sub

29. 字幕放大

Private Sub Form_Load()

Form1.Caption = \"字幕放大\" Label1.Caption = \"欢迎光临\"

12

Label1.AutoSize= True Timer1.Enabled = False Timer1.Interval = 200 End Sub

Private Sub Command1_Click()

If Command1.Caption = \"开始\" Then

Timer1.Enabled = True: Command1.Caption = \"停止\" Else

Timer1.Enabled = False: Command1.Caption = \"开始\" End If End Sub

Private Sub Timer1_Timer()

Label1.FontSize = Label1.FontSize + 2 End Sub 30. 拨号盘 Dim s As String Dim i As Integer

Private Sub Form_Load()

Form1.Caption = \"拨号键\" Text1.MaxLength = 10 Text1.FontName = \"宋体\" Text1.FontBold = True Text1.FontSize = 16 Text1.ForeColor = vbBlue

Timer1.Interval = 500: Text1.Text = \"\" Timer1.Enabled = False End Sub

Private Sub Command1_Click(Index As Integer) Text1.Text = Text1.Text + Trim(Str(Index)) End Sub

Private Sub Command2_Click() Timer1.Enabled = True s = Text1.Text Text1.Text = \"\" End Sub

Private Sub Timer1_Timer() i = i + 1

If i <= Len(s) Then

Text1.Text = Text1.Text + Mid(s, i , 1)\\ Else

Timer1.Enabled = False i=0 End If End Sub 31. 简单动画演示 Dim i As Integer

Private Sub Command1_Click() Timer1.Enabled = True End Sub

Private Sub Command2_Click() Timer1.Enabled = False End Sub

Private Sub Timer1_Timer() If i <= 4 Then

Label1(i).Visible = False

13

Label1(i + 1).Visible = True i = i + 1 Else

Label1(i).Visible = False Label1(0).Visible = True i = 0 End If End Sub 32. 改变大小 Dim a As Single, b As Single Private Sub Form_Load()

Hscroll1.Max=3400 Hscroll1.Value=3400

Shape1.Width = HScroll1.Value Shape1.Height = HScroll1.Value

Shape1.Left = 3000- Shape1.Width / 2 Shape1.Top=2000- Shape1.Height / 2 End Sub

Private Sub HScroll1_Change()

Shape1.Width = HScroll1.Value Shape1.Height = HScroll1.Value

Shape1.Left = 3000 - HScroll1.Value / 2 Shape1.Top = 2000 - HScroll1.Value / 2 Label2.Caption = HScroll1.Value End Sub

Private Sub HScroll1_Scroll()

Call HScroll1_Change End Sub 33. 作图 Private Sub Command1_Click() Picture1.Scale (-10, 10)-(10, -10) Picture1.Line (-10, 0)-(10, 0) Picture1.Line (0, -10)-(0, 10)

Picture1.CurrentX = 0: Picture1.CurrentY = 0: Picture1.Print \"(0,0)\" End Sub

Private Sub Command2_Click() Picture1.DrawWidth=2

Picture1.FillColor = vbGreen : Picture1.FillStyle = 0

Picture1.Circle (0, 0), 5, vbRed, -3.1415 / 6, -5 * 3.1415 / 6 End Sub

Private Sub Command3_Click() End End Sub 34. 画板 Private Sub Command1_Click() CommonDialog1.showcolor

Picture1.ForeColor = CommonDialog1.Color End Sub

Private Sub Command2_Click() Picture1.Cls End Sub

Private Sub Option1_Click() „粗 Picture1.DrawWidth = 5 End Sub

Private Sub Option2_Click() „细 14 Picture1.DrawWidth = 1 End Sub

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Picture1.CurrentX = X Picture1.CurrentY = Y End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then Picture1.Line -(X, Y) End Sub 35. 反弹球 Dim dx As Integer, dy As Integer Private Sub Form_Load() Timer1.Enabled = False Timer1.Interval = 100

dx = 100 „ 一开始 水平方向往右移动 dy = -100 „ 垂直方向往上移动 Shape1.Width = 500 Shape1.Height = 500 End Sub

Private Sub Mnustart_Click() Timer1.Enabled = True End Sub

Private Sub Mnustop_Click() Timer1.Enabled = False End Sub

Private Sub Timer1_Timer()

Shape1.Left = Shape1.Left + dx Shape1.Top = Shape1.Top + dy

If Shape1.Left <= 0 Or Shape1.Left >= Form1.ScaleWidth - Shape1.Width Then dx = -dx '当碰到左右边时,水平运动增量取反 End If

If Shape1.Top <= 0 Or Shape1.Top >= Form1.ScaleHeight - Shape1.Height Then dy = -dy '当碰到上下时,垂直运动增量取反 End If End Sub 36. 字体设置 Private Sub mnuback_Click() CommonDialog1.ShowColor

Text1.BackColor = CommonDialog1.Color End Sub

Private Sub mnufont_Click() CommonDialog1.flags=1 CommonDialog1.ShowFont

Text1.FontName = CommonDialog1.FontName Text1.FontSize = CommonDialog1.FontSize Text1.FontBold = CommonDialog1.FontBold Text1.FontItalic = CommonDialog1.FontItalic End Sub

Private Sub mnufore_Click()

CommonDialog1.ShowColor

Text1.ForeColor = CommonDialog1.Color End Sub 37. 图片欣赏 Private Sub Drive1_Change() Dir1.Path = Drive1.Drive

15

End Sub

Private Sub Dir1_Change() File1.Path = Dir1.Path End Sub

Private Sub File1_Click()

If Right(File1.Path, 1) <> \"\\\" Then

Image1.Picture = LoadPicture(File1.Path + \"\\\" + File1.FileName) Else

Image1.Picture = LoadPicture(File1.Path + File1.FileName) End If End Sub

Private Sub Form_Load() Drive1.Drive = \"c:\\\" Image1.Stretch = True

Form1.Caption = \"图片欣赏\" File1.Pattern = \"*.bmp;*.jpg\" End Sub 38. 文本浏览器 Private Sub Form_Load() File1.Pattern = \"*.txt\" End Sub

Private Sub Drive1_Change() Dir1.Path = Drive1.Drive End Sub

Private Sub Dir1_Change() File1.Path = Dir1.Path End Sub

Private Sub File1_Click()

Dim F As String, s As String If Right(File1.Path, 1) = \"\\\" Then F = File1.Path + File1.FileName Else

F = File1.Path + \"\\\" + File1.FileName End If

Text1.text = F

Open F For Input As #1 s = Input(Lof(1),#1) Text2.Text = s Close #1 End Sub

Private Sub File1_DblClick()

Shell \"C:\\WINNT\\Notepad.exe \" & Text1.Text „Text1里有文件路径f End Sub

如果改成input(LOF(2),2)那是不是都指2号文件,读取2号文件所有的内容

此时的 Input 是一个函数,返回指定文件中的指定个字符。 LOF 函数返回文件长度,参数为文件号。

Input 函数,第一参数为返回字符数,第二参数为文件号。 简言之,两个1都指第1号文件。

这个语句的意思是读取1号文件的所有内容。

16

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- yrrf.cn 版权所有 赣ICP备2024042794号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务