Hola de nuevo esta todo perfecto lo malo es que yo queria usar el codigo que me acabas con 2 botones browse , 2 textbox y 1 checkbox
osea este es el codigo:
Option Explicit
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Private Sub Command1_Click()
Dim OpenFile As OPENFILENAME
Dim lReturn As Long
Dim sFilter As String
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = Form1.hWnd
OpenFile.hInstance = App.hInstance
sFilter = "NyxLauncher (*.Exe)" & Chr(0) & "*.Exe" & Chr(0)
OpenFile.lpstrFilter = sFilter
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.lpstrInitialDir = "C:\"
OpenFile.lpstrTitle = "Open Nyxlauncher Location"
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "The User pressed the Cancel Button"
Else
Text1.Text = Trim(OpenFile.lpstrFile)
End If
End Sub
Private Sub GuardarPath(cadena As String)
Dim f As Long, r As String * 250
r = cadena
f = FreeFile
Open App.Path + "\path.txt" For Random As #f Len = Len(r)
Put #f, 1, r
Close #f
End Sub
Public Function AbrirPath() As String
Dim f As Long, aux As String * 250
f = FreeFile
Open App.Path + "\path.txt" For Random As #f Len = 250
Get #f, 1, aux
AbrirPath = aux
Close #f
End Function
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command4_Click()
Dim OpenFile As OPENFILENAME
Dim lReturn As Long
Dim sFilter As String
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = Form1.hWnd
OpenFile.hInstance = App.hInstance
sFilter = "NyxLauncher (*.Exe)" & Chr(0) & "*.Exe" & Chr(0)
OpenFile.lpstrFilter = sFilter
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.lpstrInitialDir = "C:\"
OpenFile.lpstrTitle = "Open Nyxlauncher Location"
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "The User pressed the Cancel Button"
Else
Text2.Text = Trim(OpenFile.lpstrFile)
End If
End Sub
Private Sub Form_Load()
Text1.Text = AbrirPath
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Check1.Value <> 0 Then
GuardarPath (Text1.Text)
End Sub
He intentado poner:
Private Sub Form_Load()
Text1.Text = AbrirPath
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Check1.Value <> 0 Then
GuardarPath (Text1.Text)
Elseif Check1.value ><0 then
GuardarPath (Text2.Text)
End Sub
pero no me funciona solo pone el mismo path del primer browser en los dos textbox.
osea este es el codigo:
Option Explicit
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Private Sub Command1_Click()
Dim OpenFile As OPENFILENAME
Dim lReturn As Long
Dim sFilter As String
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = Form1.hWnd
OpenFile.hInstance = App.hInstance
sFilter = "NyxLauncher (*.Exe)" & Chr(0) & "*.Exe" & Chr(0)
OpenFile.lpstrFilter = sFilter
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.lpstrInitialDir = "C:\"
OpenFile.lpstrTitle = "Open Nyxlauncher Location"
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "The User pressed the Cancel Button"
Else
Text1.Text = Trim(OpenFile.lpstrFile)
End If
End Sub
Private Sub GuardarPath(cadena As String)
Dim f As Long, r As String * 250
r = cadena
f = FreeFile
Open App.Path + "\path.txt" For Random As #f Len = Len(r)
Put #f, 1, r
Close #f
End Sub
Public Function AbrirPath() As String
Dim f As Long, aux As String * 250
f = FreeFile
Open App.Path + "\path.txt" For Random As #f Len = 250
Get #f, 1, aux
AbrirPath = aux
Close #f
End Function
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command4_Click()
Dim OpenFile As OPENFILENAME
Dim lReturn As Long
Dim sFilter As String
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = Form1.hWnd
OpenFile.hInstance = App.hInstance
sFilter = "NyxLauncher (*.Exe)" & Chr(0) & "*.Exe" & Chr(0)
OpenFile.lpstrFilter = sFilter
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.lpstrInitialDir = "C:\"
OpenFile.lpstrTitle = "Open Nyxlauncher Location"
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)
If lReturn = 0 Then
MsgBox "The User pressed the Cancel Button"
Else
Text2.Text = Trim(OpenFile.lpstrFile)
End If
End Sub
Private Sub Form_Load()
Text1.Text = AbrirPath
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Check1.Value <> 0 Then
GuardarPath (Text1.Text)
End Sub
He intentado poner:
Private Sub Form_Load()
Text1.Text = AbrirPath
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Check1.Value <> 0 Then
GuardarPath (Text1.Text)
Elseif Check1.value ><0 then
GuardarPath (Text2.Text)
End Sub
pero no me funciona solo pone el mismo path del primer browser en los dos textbox.