一个VB程序设计

一个VB程序设计,第1张

1、添加两个文本框和两个命令按钮,把两文本框的text属性中的Text1和Text2删除,再把命令按钮1的Caption属性改为“复制”,命令按钮2的Caption属性改为“粘贴”。2、源代码如下: Private Sub Command1_Click()Command2.Enabled = TrueCommand1.Enabled = FalseEnd Sub

Private Sub Command2_Click()Text2.Text = Text1.SelTextCommand1.Enabled = FalseCommand2.Enabled = FalseEnd Sub

Private Sub Form_Load()Command1.Enabled = FalseCommand2.Enabled = FalseEnd Sub

Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)If Text1.SelLength >0 ThenCommand1.Enabled = TrueEnd IfEnd Sub

VERSION 5.00

Begin VB.Form Form1

Caption = "Form1"

ClientHeight= 3090

ClientLeft = 60

ClientTop = 450

ClientWidth = 4680

LinkTopic = "Form1"

ScaleHeight = 3090

ScaleWidth = 4680

StartUpPosition = 3 '窗口缺省

Begin VB.CommandButton Command1

Caption = "Max!"

Height = 375

Left= 2280

TabIndex= 5

Top = 1680

Width = 975

End

Begin VB.TextBox Text5

Height = 375

Left= 960

TabIndex= 4

Top = 2160

Width = 1215

End

Begin VB.TextBox Text4

Height = 375

Left= 960

TabIndex= 3

Top = 1680

Width = 1215

End

Begin VB.TextBox Text3

Height = 375

Left= 960

TabIndex= 2

Top = 1200

Width = 1215

End

Begin VB.TextBox Text2

Height = 375

Left= 960

TabIndex= 1

Top = 720

Width = 1215

End

Begin VB.TextBox Text1

Height = 375

Left= 960

TabIndex= 0

Top = 240

Width = 1215

End

End

Attribute VB_Name = "Form1"

Attribute VB_GlobalNameSpace = False

Attribute VB_Creatable = False

Attribute VB_PredeclaredId = True

Attribute VB_Exposed = False

Private Sub Command1_Click()

Dim a(3) As Long

Dim nMax As Long

Dim i As Integer

a(0) = Val(Text1)

a(1) = Val(Text2)

a(2) = Val(Text3)

a(3) = Val(Text4)

nMax = 0

For i = 0 To 3

If nMax <a(i) Then nMax = a(i)

Next

Text5 = nMax

End Sub

把以上存为.frm即可~运行就是了。支持任意多的文本框。

'界面你会设计吧,这里把“照片、格言、结束”三个按钮定为Cmd1、Cmd2、Cmd3(记得把标题改成“照片、格言、结束”哦~)。然后放两个Image控件(这里用Image1和Image2分别代表你照片和自画图形),把你的照片放进去,再放一个Label1。。。。开始写代码哦~~

Private Sub Cmd3_Click()

End ’结束

End Sub

Private Sub Form_Click()

Dim a As String

a = InputBox("请输入信息:") ‘输入框

If a = "018" Then

Image2.Visible = True '显示自画图片

ElseIf a = "music" Then

FileCopy app.Path&"aaa.mp3" , "D:\aaa.mp3" '把文件移到D盘(前提是你的mp3文件要与你程序同文件夹)

Shell "D:\aaa.mp3" ‘假设路径为D盘,文件名为aaa.mp3(如果想要在程序内播放要另加控件)

Else

MsgBox "无效输入!"

End If

End Sub

Private Sub Form_Load()

Image1.Visible = False

Image2.Visible = False '让它们不可见

End Sub

Private Sub Cmd1_Click()

Image1.Visible = True '显示你的照片

End Sub

最后注意:在exe文件运行时,当前路径(app.path)为exe文件所在的路径。在VB中调试时,当前路径为VB所在的路径!所以调试时要注意文件路径。。

大概就是这些了。。。没疑问吧?求分分~~


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11467043.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-16
下一篇 2023-05-16

发表评论

登录后才能评论

评论列表(0条)

保存