الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كيف يتم فتح ملف عن (File List box )

مغلق
بدأه akram_awad في 8 نوفمبر 2006 · 1 رد · 510 مشاهدة · في لغة Ms Visual Basic 6 وما قبلها من إصدارات
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

كيف أفتح الملف يا أخوان

عن طريق النقر فوق الملف المطلوب

علماً أني أستخدمت الكود الآتي

Private Sub Command1_Click()

Dim filename As String

'On Error GoTo fileError

If (Right$(Dir1.Path, 1) = "\") Then

filename = File1.Path & File1.filename

Else

filename = File1.Path & "\" & File1.filename

End If

Open filename For Input As #1

'Text1.Text = Input$(LOF(1), #1)

Close #1

Exit Sub

'fileError:

'MsgBox " File Error "

End Sub

Private Sub Dir1_Change()

File1.Path = Dir1.Path

End Sub

Private Sub Drive1_Change()

Dir1.Path = Drive1.Drive

End Sub

Private Sub File1_Click()

Command1_Click

End Sub

#2
Option Explicit
Dim FilePath As String
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As VbAppWinStyle) As Long

Private Sub ShellAnyFile(FormName As Form, FilePath As String, Optional CommandLines As String = "", Optional WorkingDirectory As String = "", Optional WinState As VbAppWinStyle = vbNormalFocus)
ShellExecute FormName.hwnd, vbNullString, FilePath, CommandLines, WorkingDirectory, WinState
End Sub

Private Sub Dir1_Change()
On Error GoTo err_trap

File1.Path = Dir1.Path

Exit Sub
err_trap:
MsgBox "Error occurred , " & Err & " , " & Error
End Sub

Private Sub Drive1_Change()
On Error GoTo err_trap

Dir1.Path = Drive1.Drive

Exit Sub
err_trap:
MsgBox "Error occurred , " & Err & " , " & Error
If Err = 68 Then Drive1.Drive = Left$(Dir1.Path, 3)
End Sub

Private Sub File1_DblClick()
On Error GoTo err_trap

FilePath = File1.Path
If Right$(FilePath, 1) <> "\" Then FilePath = FilePath & "\"
FilePath = FilePath & File1.FileName

If File1.ListIndex > -1 Then ShellAnyFile Me, FilePath

Exit Sub
err_trap:
MsgBox "Error occurred , " & Err & " , " & Error
End Sub

هذا الموضوع مغلق.

مواضيع مشابهة