程序示例:
程序功能说明:
在窗体的file1中选择一个图片文件,点选“预览”复选框,image控件就显示相应的图片,label1就显示该图片的大小。
新建一个工程,加入以下控件:
控件 名称 属性
form form1 borderstyle=3
(vbsizedouble)
caption=“图片预览对话框"
drivelistbox drive1
dirlistbox dir1
filelistbox file1 pattern=“*.bmp;
*.jpg;*.gif"
image image1 stretch=true
checkbox chk value=“预览"
commandbutton cmd1 caption=“确定"
cmd2 caption=“退出"
label lab1 caption=“"
源代码:
以下是引用片段:
'declare
Public filename$
dim sfilename$
Private sub drive1_change()
dir1.path=drive1.drive
End sub
Private sub dir1_change()
file1.path=dir1.path
End sub
Private sub cmd1_click()
filename=sfilename
End sub
Private sub cmd2_click()
End
End sub
Private sub file1_click()
dim ssize as long
if fille1.listcount>0 then
if right(file1.path,1)<>“\" then
sfilename=file1.path&“\"&file1.filename
else
sfilename=file1.path&file1.filename
End if
if chk.checked then
image1.picture=loadpicture(“")
image1.picture=loadpicture(sfilename)
ssize=filelen(sfilename)
ssize=ssize/1000
lab1.caption=str(ssize)&“k"
else
lab1.caption=“"
image1.picture=loadpicture(“")
end if
end if
End sub
【VisualBasic中实现带预览的对话框】相关文章:
2025年外省高中学业水平合格性考试成绩转入江苏认定的通告公布03-23
Vb中控件的自动排列03-23
写未来的作文300字03-23
Our Mother Is the Same 我们的妈妈是一样的03-23
中国大地保险公司实习报告03-23
小学父爱的作文600字03-23
07年4月北师大“中国古代文学史(一)”串讲(5)03-23
汪涵讲述小时候成长经历:鸡毛掸子的故事03-23
2023年广东梅州中考成绩查询时间及查分入口[7月7日起]03-23
关于清明节的英语作文:清明节03-23
