急!如何VB文件列表框双击文件名在文本框中显示文件内容?
imjj%,ch$PrivateSubForm_Load()Text1.Text=""Drive1.Drive=Left(App.Path,1)Command1.Capt...
im jj%, ch$
Private Sub Form_Load()
Text1.Text = ""
Drive1.Drive = Left(App.Path, 1)
Command1.Caption = "打 开"
End Sub
Private Sub drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub File1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'If File1.ListCount > 0 Then
Text1.Text = IIf(Right(Dir1.Path, 1) = "\", Trim(Dir1.Path) & File1.FileName, Trim(Dir1.Path) & "\" & File1.FileName)
'Shell "explorer " & text1.text, vbNormalFocus
'End If
End Sub
Private Sub Command1_Click()
ch = UCase(getext(Text1.Text))
'只能打开 TXT DOC BMP VBP
If ch = "TXT" Or ch = "DOC" Or ch = "BMP" Or ch = "VBP" Then
Shell "explorer " & Text1.Text, vbNormalFocus
Else
MsgBox "文件类型选择错误", 5, "提示信息"
Text1.Text = ""
End If
End Sub
Function getext(tstr As String) As String
jj = InStrRev(Text1.Text, ".")
If jj > 0 Then getext = UCase(Mid(Text1.Text, jj + 1))
End Function
各位大哥,不好意思,发错问题了,正确问题在以下网页:
http://zhidao.baidu.com/question/100387685.html 展开
Private Sub Form_Load()
Text1.Text = ""
Drive1.Drive = Left(App.Path, 1)
Command1.Caption = "打 开"
End Sub
Private Sub drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub File1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'If File1.ListCount > 0 Then
Text1.Text = IIf(Right(Dir1.Path, 1) = "\", Trim(Dir1.Path) & File1.FileName, Trim(Dir1.Path) & "\" & File1.FileName)
'Shell "explorer " & text1.text, vbNormalFocus
'End If
End Sub
Private Sub Command1_Click()
ch = UCase(getext(Text1.Text))
'只能打开 TXT DOC BMP VBP
If ch = "TXT" Or ch = "DOC" Or ch = "BMP" Or ch = "VBP" Then
Shell "explorer " & Text1.Text, vbNormalFocus
Else
MsgBox "文件类型选择错误", 5, "提示信息"
Text1.Text = ""
End If
End Sub
Function getext(tstr As String) As String
jj = InStrRev(Text1.Text, ".")
If jj > 0 Then getext = UCase(Mid(Text1.Text, jj + 1))
End Function
各位大哥,不好意思,发错问题了,正确问题在以下网页:
http://zhidao.baidu.com/question/100387685.html 展开
2个回答
展开全部
看了你的问题了。。。楼主给我分啊。。。我已经帮你答了啊!!!!
修改file_dblclick如下
Private Sub file_dblclick()
Dim s$
If Right(File1.Path, 1) = "\" Then
fName = File1.Path + File1.FileName
Else
fName = File1.Path + "\" + File1.FileName
End If
Text1.Text = fName
Text1.MultiLine = True
Open fName For input As #1
Do until EOF(1)
Line Input #1, s
Text1.Text = Text1.Text & chr(13) & chr(10) & s
Loop
Close #1
End Sub
修改file_dblclick如下
Private Sub file_dblclick()
Dim s$
If Right(File1.Path, 1) = "\" Then
fName = File1.Path + File1.FileName
Else
fName = File1.Path + "\" + File1.FileName
End If
Text1.Text = fName
Text1.MultiLine = True
Open fName For input As #1
Do until EOF(1)
Line Input #1, s
Text1.Text = Text1.Text & chr(13) & chr(10) & s
Loop
Close #1
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询