+ Reply to Thread
Results 1 to 15 of 15

Explain This??

  1. #1
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Explain This??

    Hi all,

    I don't want to bloat the water cooler anymore than what it is but I thought this may be a cool thread to start for those of us that like to learn and understand what we are learning. Hence the title Explain This??!

    To start, can someone explain this:
    Please Login or Register  to view this content.
    More specifically, what does fnum represent and why use # before it?
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,928

    Re: Explain This??

    To quote the help:
    "FreeFile Function: Returns an Integer representing the next file number available for use by the Open statement."
    This saves you having to keep track of what file numbers you may already have used.

    In this case:

    Please Login or Register  to view this content.

    The next free file number is assigned to the variable fnum which is then used to open the file to write to it.

    I'm not sure why the # is there, I suspect it is just to indicate an integer variable.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Explain This??

    In file I/O, files are represented by Integer types. FreeFile() is a function which returns the next available file number (between 1 to 511) which can be used with the Open statement.

    The # convention is inherited from older versions of basic. Note that in this case it does not represent a Double!
    Hope that helps,

    Colin

    RAD Excel Blog

  4. #4
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Explain This??

    Thanks for that guys, if tipping your scales meant anything in the Water Cooler I would do it.

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Explain This??

    To learn what freefile does:

    Please Login or Register  to view this content.
    Most of the time I close a file that has been opened with 'Open' before I open another one.

    In that case the only code I need is:
    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.
    Instead of reading line by line using 'read' use Input(LOF(1),1) to read the whole filecontent in 1 go.

    Instead of writing line by line using 'write' use Print to write the whole content into the file in 1 go.

    PS. I wouldn't object seeing this kind of question in the Excel programming subforum. (seems even more appropriate to me)
    Last edited by snb; 06-03-2011 at 09:43 AM.



  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Explain This??

    Quote Originally Posted by Mordred View Post
    Thanks for that guys, if tipping your scales meant anything in the Water Cooler I would do it.
    I think this would have been good for the general programming forum... obviously with a more suitable title
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  7. #7
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Explain This??

    Quote Originally Posted by NBVC View Post
    I think this would have been good for the general programming forum... obviously with a more suitable title
    Well, you're a mod boss and can move it! I didn't want to start this thread anywhere else because I didn't want to get into trouble from the mods.

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Explain This??

    Other than the title, what would have gotten you into trouble?

  9. #9
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Explain This??

    LoL, I don't know but so far I haven't received any infractions from you good people and I don't want any! Also, the title is allowed in the water cooler so....

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Explain This??

    Well.. there is a rule about posting in the relevant forum...could get you there

    anyways... just kidding....

  11. #11
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Explain This??

    At least for me, maybe the title is allowed, but a proper title would give those surfers a glimpse into what's in the thread

    Thoughts to consider...
    HTH
    Regards, Jeff

  12. #12
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Explain This??

    What is the definition of a Sticky thread? I see those in the regular forums, do scale taps count there?

  13. #13
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Explain This??

    See: Sticky Threads

    It's usually used for threads that mods and admin want not to get lost in the haystack and are considered very useful or important threads.

    I think scales works there... but not 100% sure.. RoyUK should be able to answer that...

  14. #14
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Explain This??

    @NBVC We can test the scales in sticky threads. submit something in the sticky thread in the Programming part of the forum and I'll tap your scales.

  15. #15
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Explain This??

    There is a sticky thread there called "Thanks for all the help". Tip the original OP's scales on the very first post.... and then let me know when done, and I can check if he got the points.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1