或者
使用下述代码
Private Sub Form_Load()
Picture1.Picture = LoadPicture(App.Path &"\123.jpg")
End Sub
前提是程序所在目录必须有123.jpg这个文件
简单的实现方法:在PictureBox中加入一个Label控件,利用这个Label显示文字。将Label背景设置为透明,所显示的文字不会影响画面。
具体实现方法如下:
(1)在窗体Form1上布置一个PictureBox,将一个Label拖入到PictureBox内。再在窗体上布置一个TextBox
在PictureBox中载入一个图片;将label1的BackStyle属性设置为: 0 -Transparent
(2)窗体代码
Option ExplicitPrivate Sub Form_Load()
Label1.Caption = ""
Text1.Text = ""
End Sub
Private Sub Text1_Change()
Label1.Caption = Text1.Text
End Sub
(3)运行效果
'Dim WithEvents NewText As TextBoxPrivate Sub Command1_Click()
For i = 1 To 4
sname = "Txt" &i
Set NewText = Controls.Add("VB.TextBox", sname)
NewText.Move 2000, 500 * i, 1000, 360
Controls(sname).Text = "文本框" &i
NewText.Visible = True
Next i
End Sub
Private Sub Command2_Click()
For i = 1 To 4
sname = "Cmdnew" &i
Set NewButton = Controls.Add("VB.CommandButton", sname)
NewButton.Move 500, 500 * i, 1000, 360
Controls(sname).Caption = "按钮" &i
NewButton.Visible = True
Next i
End Sub
Private Sub Command3_Click()
For i = 1 To 4
BqName = "Lbl" &i
Set Newlbl = Controls.Add("VB.Label", BqName)
Newlbl.Move 3500, 500 * i, 1000, 360
Controls(BqName).Caption = "标签" &i
Newlbl.Visible = True
Next i
End
'Set Newlbl = Controls.Add("VB.Label", BqName)中,Label可替换成工具箱中任意控件类名
更多VB代码可参阅我的博客:http://hi.baidu.com/zgmg/blog/item/c1a68eec0fabdb2b63d09f5b.html#
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)