Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 8th, 2007, 07:00 PM
Friend of Wrox
Points: 1,075, Level: 12
Points: 1,075, Level: 12 Points: 1,075, Level: 12 Points: 1,075, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2005
Location: , , United Kingdom.
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default ByRef Argument!

What is a ByRef Argument Type Mismatch?? Any ideas, this is the code im using also if its any help im using the microsoft scripting runtime reference!

Code:
Dim FSO As Scripting.FileSystemObject
Dim Folder As String
Folder = "C:\Files"
Set FSO = New Scripting.FileSystemObject
If FSO.FolderExists(Folder) Then
FindFiles (Folder)
Else
MsgBox "Folder Doesn't exist :S"
End If
Now the FindFiles is a function which in the brackets requires this
Code:
FindFiles(dirDirectory As Scripting.Folder)
Any ideas?

Cheers


------------------------------------------------
Apocolypse2005
Always ready and waiting to be helped!
__________________
Apocolypse2005, I'm a programmer - of sorts.
Reply With Quote
  #2 (permalink)  
Old August 8th, 2007, 11:32 PM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

FindFiles(dirDirectory As Scripting.Folder) Function expects the reference type as Scripting.Folder

whereas you are passing a string named 'Folder'

FindFiles (Folder)

That is the cause for the error

Regards
Shasur

http://www.dotnetdud.blogspot.com
Reply With Quote
  #3 (permalink)  
Old August 9th, 2007, 06:36 AM
Friend of Wrox
Points: 1,075, Level: 12
Points: 1,075, Level: 12 Points: 1,075, Level: 12 Points: 1,075, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2005
Location: , , United Kingdom.
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default

Im using this new code, but now im getting a type mismatch the cmdSearch is getting highlighted in yellow d the statement FindFiles (Folder) is highlight in blue(normal text highlight)
Code:
Private Sub cmdSearch_Click()
Dim FSO As Scripting.FileSystemObject
Dim Folder As Scripting.Folder

Set FSO = New Scripting.FileSystemObject
Set Folder = FSO.GetFolder("C:\Files")

If FSO.FolderExists(Folder) Then
FindFiles (Folder) 'This is highlighted!
Else
MsgBox "Folder Doesn't exist :S"
End If

End Sub
Any ideas?!

Cheers

------------------------------------------------
Apocolypse2005
Always ready and waiting to be helped!
Reply With Quote
  #4 (permalink)  
Old August 9th, 2007, 08:14 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there.. maybe an error inside findfiles????

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
Reply With Quote
  #5 (permalink)  
Old August 9th, 2007, 11:57 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

What is this "FindFiles()?" It appears to be something you (the generic you) have written. I find no such routine in the Scripting library, or in the VB libraries.

Putting the argument in parens indicates that it is a function, and will return something, yet you have nothing set to do that receiving. So it should be
Code:
    <Something> = FindFiles(Folder)
    Set <Something> = FindFiles(Folder)
    ' Or
    FindFiles Folder
    What does FindFiles() do?

Could you use better-formed text in your posts? [u]You</u> know what you mean, but [u]we</u> have to rely on what you type. For instance, “. . . , but now im getting a type mismatch the cmdSearch is getting highlighted in yellow . . . ” doesn't actually mean anything. (Plus, it is standard to capitalize “I.” Plus, contractions—‘im’ should be ‘I’m’—require apostrpophes. Sometimes making haste slows things down...) It appears to mean, “. . . , but now im getting a type mismatch. The statement ‘cmdSearch’ is getting highlighted in yellow . . . ” (You did say “Always ready and waiting to be helped!” Just trying to help...)

If that’s right, that’s the behavior when a routine (cmdSearch() in this case) won’t compile. (When the routine compiles but hits an error while trying to execute a given line, then that individual line is highlighted.) The highlight indicates the progress of the running. Everything up to the highlight has run, but it is stopped trying to execute at that which is highlit. So knowing more about FindFiles() would help resolve where the problem lies.
Reply With Quote
  #6 (permalink)  
Old August 9th, 2007, 01:39 PM
Friend of Wrox
Points: 1,075, Level: 12
Points: 1,075, Level: 12 Points: 1,075, Level: 12 Points: 1,075, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2005
Location: , , United Kingdom.
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default

Just for you mr wren!
the findfiles is a function created by me the (generic me), here is the code!
Code:
Sub FindFiles(dirDirectory As Scripting.Folder)
Dim FSFile As Scripting.File

For Each FSFile In dirDirectory.Files
If LCase(Right(.Name, 4)) = ".txt" Then
AddFiles FSFile.Name
End If
Next FSFile

Set FSFile = Nothing

End Sub
Have a browse on that!


------------------------------------------------
Apocolypse2005
Always ready and waiting to be helped!
Reply With Quote
  #7 (permalink)  
Old August 9th, 2007, 01:54 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

if you trace this code it's get goes ok?? what if a file name is "a" (just a letter, only one, the right will fail)

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
Reply With Quote
  #8 (permalink)  
Old August 9th, 2007, 01:57 PM
Friend of Wrox
Points: 1,075, Level: 12
Points: 1,075, Level: 12 Points: 1,075, Level: 12 Points: 1,075, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2005
Location: , , United Kingdom.
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default

Well i've tried to F8 it (step by step on each line) but as soon as i click on the button it just straight to an error, i dont know how to go through the findfiles step by step.
Reply With Quote
  #9 (permalink)  
Old August 9th, 2007, 02:07 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

ok.. try the functions on my vb..

it fails because of this:
Code:
FindFiles Folder
(remove this () )

and it will work.. but take in mind what I tell you about filenames...

and also this line is wrong:
Code:
If LCase(Right(.Name, 4)) = ".txt" Then
should be:
Code:
If LCase(Right(FSFile.Name, 4)) = ".txt" Then
HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
Reply With Quote
  #10 (permalink)  
Old August 9th, 2007, 02:12 PM
Friend of Wrox
Points: 1,075, Level: 12
Points: 1,075, Level: 12 Points: 1,075, Level: 12 Points: 1,075, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2005
Location: , , United Kingdom.
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default

Hmmm, well my comp crashed last night when i was sorting all that out and of course it wasnt saved so i'll have to go back and change that again. Thanks alot for the help, it was actually helpful, lol!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ByRef property rolandatem VB.NET 2002/2003 Basics 1 October 8th, 2005 08:42 AM
byRef ? g2000 Classic ASP Basics 0 August 18th, 2005 09:37 AM
ByRef and ByVal kgs51 Beginning VB 6 2 November 2nd, 2004 08:09 PM
byref Argument type mismatch in vb Vijay_VB VB How-To 1 August 16th, 2004 08:53 AM
Arrays seem to be passed byRef always srbeckle VB.NET 2002/2003 Basics 0 July 25th, 2003 10:36 AM



All times are GMT -4. The time now is 02:33 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.