关于“VB中实现带预览的对话框”不能做通的问题

来源:百度知道 编辑:UC知道 时间:2024/06/25 18:35:28
网上有文章“VB中实现带预览的对话框”,经更改后(小改),但做来做去做不通,不知什么原因。经更改后的程序如下:
Dim Ssize As Long
Dim SFileName As String
Dim Ssize As Integer

Private Sub Cmd2_Click()
End
End Sub

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

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

Private Sub Form_Load()
Form1.BorderStyle = 3
Form1.Caption = "图片预览对话框"
File1.Pattern = "*.bmp;*.jpg;*.gif"
Image1.Stretch = True
Cmd1.Caption = "确定"
Cmd2.Caption = "退出"
Lab1.Caption = ""
End Sub

Private Sub cmd1_click()
FileName = SFileName
End Sub

Private Sub file1_click()
If File1.ListCount > 0 Then
If Right(File1.Path, 1) <> "\" Then
SFileName = File1.Path & "\" & File1.FileName
Else
SFileName = File1.Path & Fi

把这些文字放到txt文件中,然后把txt文件后缀改为frm,用vb打开这个frm文件就能运行了。这时是窗口文件的全部代码,后半部分就是你写的代码,前半部分是控件代码。所有的frm文件都能用txt打开的。

VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 7455
ClientLeft = 120
ClientTop = 420
ClientWidth = 8055
LinkTopic = "Form1"
ScaleHeight = 7455
ScaleWidth = 8055
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Cmd2
Caption = "Command2"
Height = 735
Left = 5640
TabIndex = 5
Top = 1320
Width = 1575
End
Begin VB.CommandButton Cmd1
Caption = "Command1"
Height = 615
Left = 5640
TabIndex = 4
Top = 360<