Hi, i have a sub form_load() and a sub process_click() but i dont know how to connect them. meaning the variables i used in form_load() i want to be able to use in process_click(). both are public subs and here is the code from both: your help is greatly appreciated...thanks
Public Sub Form_Load()
flag = dataDirectory & "\temp.txt"
Ix2 = 4 'Initial index
KSlash2 = InStr(1, flag, "\", 1) 'Search For first "\"
For Cntflag = 1 To Len(flag) 'Run until discover
'other directories
KSlash2 = InStr((KSlash2 + 1), flag, "\", 1)
If KSlash2 = 0 Then Exit For 'Last slash
dir12 = Left(flag, (KSlash2 - 1))
cdir12 = Mid(dir12, Ix)
Ix2 = Ix2 + Len(cdir12) + 1
hh2 = Dir(dir12)
If Dir(flag, vbDirectory) <> "" Then
'MkDir (dir12 & "\temp"
MsgBox ("flag exists"
'backup files from Ptemp to dataDirectory
CopyFile Pfolder, dataDirectory, p
MsgBox "Number of files copied = " & Str$(p)
Else
'flag doesnt exist, copy data directory to Ptemp
MsgBox ("flag doesn't exists"
CopyFile dataDirectory, Pfolder, p
MsgBox "Number of files copied = " & Str$(p)
End If
Next Cntflag
end sub
Public Sub Process_Click()
MsgBox ("You chose " & TimePeriods.List(TimePeriods.ListIndex))
Open flag For Output As #1
Close #1
End Sub
Ok, the open flag for output does not work because it seems that the sub doesnt know what flag is.
thank you again
Public Sub Form_Load()
flag = dataDirectory & "\temp.txt"
Ix2 = 4 'Initial index
KSlash2 = InStr(1, flag, "\", 1) 'Search For first "\"
For Cntflag = 1 To Len(flag) 'Run until discover
'other directories
KSlash2 = InStr((KSlash2 + 1), flag, "\", 1)
If KSlash2 = 0 Then Exit For 'Last slash
dir12 = Left(flag, (KSlash2 - 1))
cdir12 = Mid(dir12, Ix)
Ix2 = Ix2 + Len(cdir12) + 1
hh2 = Dir(dir12)
If Dir(flag, vbDirectory) <> "" Then
'MkDir (dir12 & "\temp"
MsgBox ("flag exists"
'backup files from Ptemp to dataDirectory
CopyFile Pfolder, dataDirectory, p
MsgBox "Number of files copied = " & Str$(p)
Else
'flag doesnt exist, copy data directory to Ptemp
MsgBox ("flag doesn't exists"
CopyFile dataDirectory, Pfolder, p
MsgBox "Number of files copied = " & Str$(p)
End If
Next Cntflag
end sub
Public Sub Process_Click()
MsgBox ("You chose " & TimePeriods.List(TimePeriods.ListIndex))
Open flag For Output As #1
Close #1
End Sub
Ok, the open flag for output does not work because it seems that the sub doesnt know what flag is.
thank you again