|
-
Apr 19th, 2002, 11:26 AM
#1
Thread Starter
Hyperactive Member
Little Problem?
I'm using this code to try to kame 2 different controls but when I try to run my app I get a compile error: agrument not optional.
Why?
VB Code:
ListFiles (CheckPath(App.Path) & "Favorites\")
ListhFiles = (CheckPath(App.Path) & "history\")
Public Sub ListFiles(sFolder As String)
Dim i As Integer
Dim sFilename As String
Dim iCount As Integer
Dim FSO As New FileSystemObject
iCount = 1
' Remove flags for files you don't want to include
sFilename = Dir(FSO.BuildPath(sFolder, "*.wwu"), vbNormal Or vbHidden Or vbSystem Or vbReadOnly)
sFilename = Left(sFilename, InStrRev(sFilename, ".") - 1)
On Error Resume Next
mnuViewFiles(0).Caption = sFilename
mnuViewFiles(0).Visible = True
Do
sFilename = Dir() ' Get next filename
If Trim$(sFilename) = vbNullString Then Exit Sub
Load mnuViewFiles(iCount)
sFilename = Left(sFilename, InStrRev(sFilename, ".") - 1)
mnuViewFiles(iCount).Caption = sFilename
mnuViewFiles(iCount).Visible = True
iCount = iCount + 1
Loop
End Sub
Private Function NormalizePath(sFolder As String, hfolder As String) As String
sFolder = Trim$(sFolder)
hfolder = Trim$(hfolder)
If Right$(sFolder, 1) <> "\" Then sFolder = sFolder & "\"
NormalizePath = sFolder
If Right$(hfolder, 1) <> "\" Then sFolder = hfolder & "\"
NormalizePath = hfolder
End Function
Public Sub ListhFiles(hfolder As String)
Dim i As Integer
Dim hFilename As String
Dim iCount As Integer
Dim FSO As New FileSystemObject
iCount = 1
' Remove flags for files you don't want to include
hFilename = Dir(FSO.BuildPath(hfolder, "*.wwu"), vbNormal Or vbHidden Or vbSystem Or vbReadOnly)
hFilename = Left(hFilename, InStrRev(hFilename, ".") - 1)
On Error Resume Next
Toolbar1.Buttons(1).ButtonMenus(0).Text = hFilename
Toolbar1.Buttons(1).ButtonMenus(0).Visible = True
Do
hFilename = Dir() ' Get next filename
If Trim$(hFilename) = vbNullString Then Exit Sub
Load Toolbar1.Buttons(1).ButtonMenus(iCount)
hFilename = Left(hFilename, InStrRev(hFilename, ".") - 1)
Toolbar1.Buttons(1).ButtonMenus(iCount).Text = hFilename
Toolbar1.Buttons(1).ButtonMenus(iCount).Visible = True
iCount = iCount + 1
Loop
End Sub
-
Apr 19th, 2002, 11:32 AM
#2
I didnt read your code, but it means you're calling a function and you are not passing one or more arguments. Like a function might need you to call it like FUNCTION (ARG) and you are not passsing ARG, like you're just calling FUNCTION()
Umm, maybe you're not getting the returned variable
change the first line to this, see if this helps
call ListFiles (CheckPath(App.Path) & "Favorites\")
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Apr 19th, 2002, 11:34 AM
#3
I'd be willing to bet your problem is here
VB Code:
If Right$(sFolder, 1) <> "\" Then sFolder = sFolder & "\"
NormalizePath = sFolder
If Right$(hfolder, 1) <> "\" Then sFolder = hfolder & "\"
NormalizePath = hfolder
You can't just say NormalizePath. This function is expecting to be passed two paraemeters (sFolder As String, hfolder As String) and you aren't passing it any parameters.
-
Apr 19th, 2002, 11:47 AM
#4
Thread Starter
Hyperactive Member
the error is on ListhFiles = (CheckPath(App.Path) & "history\")
would it still have something to do with th normalizepath?
-
Apr 19th, 2002, 12:21 PM
#5
Thread Starter
Hyperactive Member
Could you please suggest a way to fix my code?
-
Apr 19th, 2002, 02:42 PM
#6
Thread Starter
Hyperactive Member
I will keep this post on top until I get an answer!
-
Apr 19th, 2002, 02:45 PM
#7
Addicted Member
What or where is the CheckPath() function?
-
Apr 19th, 2002, 07:44 PM
#8
Thread Starter
Hyperactive Member
the checkpath() function is to locate the app's path nomatter where the app's dir is located.
and the checkpath() function is located at the near top of the code page just after the declarations and just before the form load Sub.
Why?
-
Apr 19th, 2002, 07:59 PM
#9
ListFiles (CheckPath(App.Path) & "Favorites\")
ListhFiles = (CheckPath(App.Path) & "history\")
Are these calls inside a sub?
-
Apr 19th, 2002, 08:26 PM
#10
PowerPoster
Why are you passing two folders to NormalizePath? I think it should be like this:
VB Code:
Function NormalizePath(ByRef sFolder As String)
sFolder = Trim$(sFolder)
If Right$(sFolder, 1) <> "\" Then sFolder = sFolder & "\"
End Function
-
Apr 19th, 2002, 08:27 PM
#11
Thread Starter
Hyperactive Member
yup, the form_load sub, but never mind I fixed the problem I just removed the "=" and every thing worked
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|