供应链金融的劣势:VB开发平台的组成 ?

来源:百度文库 编辑:中科新闻网 时间:2024/05/05 11:59:37
知道滴高手告诉小弟一下。。
在次谢谢…………

VB编程实例
--------------------------------------------------------------------------------

1.增加新按钮程序清单(增加新按钮.exe)
注意:本程序较难。
'指出下面所使用的新变量必须先声明,这样会自动纠错
Option Explicit
'通过使用WithEvents关键字声明一个对象变量为新的命令按钮
Private WithEvents NewButton As CommandButton
Private Sub cmd_add_Click()
If NewButton Is Nothing Then
'增加新的按钮cmdNew
Set NewButton = Controls.Add("vb.commandButton", "cmdnew", Me)
NewButton.Move cmd_add.Left, cmd_add.Top - 580, cmd_add.Width
NewButton.Caption = "新增的按钮"
NewButton.Visible = True
Else
MsgBox "你已经增加了新的按钮!", 0, "提示框"
End If
End Sub

Private Sub cmd_minus_Click()
If NewButton Is Nothing Then
MsgBox "你没有增加新按钮!", 0, "提示框"
Else
Controls.Remove NewButton
Set NewButton = Nothing
End If
End Sub

Private Sub cmd_test_Click()
If NewButton Is Nothing Then
MsgBox "你没有增加新的按钮!", 0, "提示框"
Else
NewButton.Caption = "测试成功!"
End If
End Sub

'新增控件的单击事件
Private Sub NewButton_Click()
MsgBox "您选中的是动态增加的按钮", 0, "提示框"
End Sub

2. 文本框之间用TAB键切换的程序清单(文本框切换.exe)
注意:本程序需要建立文本框组。
Private Sub Command1_Click()
Unload Me
End Sub
'文本框内的文本反白显示
Private Sub Text1_GotFocus(Index As Integer)
Text1(Index).SelStart = 0
Text1(Index).SelLength = Len(Text1(Index).Text)
End Sub
'设置回车与TAB键功能相同
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
SendKeys "{tab}"
End If
End Sub

3. 在不同位置插入文本的程序清单(插入文本.exe)
'注意:本程序需要建立optionbutton组,并把该组建立在frame框中。
Private Sub Command1_Click()
Text1.Text = "天津大学职教学院"
Option1(0).Value = True
Image1.Picture = LoadPicture("d:\11\20.jpg")
Picture1.Picture = LoadPicture("d:\11\21.jpg")
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Image1_Click()
Image1.Picture = LoadPicture("d:\11\11.jpg")
End Sub

Private Sub Option1_Click(Index As Integer)
Select Case Index
Case 0
Text1.SelStart = 0
Text1.SetFocus
Case 1
Text1.SelStart = Len(Text1.Text)
Text1.SetFocus
Case 2
Text1.SelStart = 5
Text1.SetFocus
Case 3
Text1.SelStart = 0

Text1.SelLength = Len(Text1.Text)
Text1.SetFocus
Case 4
Text1.SelText = "刘二杰"
Text1.SetFocus

End Select

End Sub

Private Sub Picture1_Click()
Picture1.Picture = LoadPicture("d:\11\22.jpg")
End Sub

Private Sub Text1_GotFocus()
'Text1.SelStart = 0
'Text1.SelLength = Len(Text1.Text)
End Sub

4.动态显示汉字的程序清单(动态显示汉字.exe)
注意:本程序关键在于:增加一个timer控件。通过变量i来控制截取汉字。
Dim i As Integer

Private Sub Form_Load()
Form1.Picture = LoadPicture("d:\temp\zhaowei1.bmp")
End Sub

Private Sub Timer1_Timer()
Dim str1 As String
str1 = "美不美、看赵薇、浪不浪、看长象 " '显示信息
len1 = Len(str1)
With Text1
.FontSize = 16
.FontName = "隶书"
.ForeColor = &HFF&
.BackColor = &HFFFF&
End With
str2 = Mid$(str1, i + 1, 1)
'一个字一个字地显示
SendKeys str2
i = i + 1
If (i + 1) > len1 Then
SendKeys "{enter}" '换行
i = 0
End If
End Sub

5.玩游戏看赵薇(玩游戏看赵薇.exe)
注意:随机函数的应用,图片随鼠标单击而改变(图片名字有一定的规律)。
Dim i As Integer
Dim str1 As String
Dim str2 As String
Dim j As String
Dim str As String

Private Sub Command1_Click()
i = 1
Image1.Visible = False '隐藏硬币图像
Label5.Caption = ""
Label7.Caption = ""
Label8.Caption = ""
Label1.Caption = Int(Rnd * 10)
Label2.Caption = Int(Rnd * 10)
Label3.Caption = Int(Rnd * 10) '当某个标题为7时,显示一堆硬币并响铃
If (Label1.Caption = 7) Or (Label2.Caption = 7) _
Or (Label3.Caption = 7) Then
Image1.Visible = True
Label5.Caption = "恭喜!您赢了!"
Label7.Caption = "单击图片"
Label8.Caption = "不同享受"
Beep
End If
End Sub

Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Randomize
End Sub

Private Sub Image1_MouseUp(Button As Integer, Shift As Integer,
X As Single, Y As Single)
str2 = "1234567"
str1 = "d:\123\mime"
j = Mid$(str2, i, 1)
str = str1 & j & ".wmf"
Image1.Picture = LoadPicture(str)
i = i + 1
If i > 7 Then
Image1.Picture = LoadPicture("d:\123\mime8.bmp")
i = 1
End If
End Sub

6.磁盘目录文件的选择
注意:磁盘、目录、文件控件的添加,另外对于文件控件的pattern="*.bmp;*.wmf;*.jpg"

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

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

Private Sub File1_Click()
selectedfile = File1.Path & "\" & File1.FileName
Image1.Picture = LoadPicture(selectedfile)
End Sub

7.登录框的程序清单(登录框.exe)

注意:设置变量
Option Explicit

Public LoginSucceeded As Boolean

Private Sub cmdCancel_Click()
'设置全局变量为 false
'不提示失败的登录
LoginSucceeded = False
End
End Sub

Private Sub cmdOK_Click()
'检查正确的密码
If txtPassword = "password" Then
'将代码放在这里传递
'成功到 calling 函数
'设置全局变量时最容易的
LoginSucceeded = True
End
Else
MsgBox "无效的密码,请重试!", , "登录"
txtPassword.SetFocus
SendKeys "{Home}+{End}"

End If
End Sub

8.图片切换的程序清单(图片切换.exe)
注意:本程序需要建立三个form窗体

form1的代码如下:

Private Sub Form_Click()
Form1.Hide
Form2.Show
End Sub

Private Sub Form_Load()
Form1.Caption = "天津大学职教学院"
Form1.Picture = LoadPicture("d:\图画\snowhous.wmf")
End Sub
Private Sub Command1_Click()
Form1.Height = Form1.Height - 200
Form1.Width = Form1.Width - 300
End Sub

Private Sub Command2_Click()
Form1.Height = Form1.Height + 200
Form1.Width = Form1.Width + 300
End Sub

form2的代码如下:

Private Sub Form_Click()
Form2.Hide
Form3.Show
End Sub

Private Sub Form_Load()
Form2.Caption = "天津大学职教学院"
Form2.Picture = LoadPicture("d:\图画\space1.wmf")
End Sub

form3的代码如下:

Private Sub Form_Click()
Form3.Hide
Form1.Show
End Sub

Private Sub Form_Load()
Form3.Caption = "天津大学职教学院"
Form3.Picture = LoadPicture("d:\图画\3cross.wmf")
End Sub