Page 1 of 2 12 LastLast
Results 1 to 15 of 28
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Code: getting started

    I'm about to post the first few procedures; the goal is to give you a neat way of managing your INI files.

    Moderator has been set the task or organising my brain, so these might be interim postings, but what the heck, let's make a start.

    Your mission, should you choose to accept it, is to test and comment on these procedures as they appear.

    1. I recommend you create a new directory that will house all work associated with building these apps. I have made one called WOODY, and used good Manjimup jarrah (that's a joke for Geoff)

    2. In Word97 or later, create a template (File, New, click on Template) and save it with a unique name in your Woody folder.

    3. In Word97 open the VBE (Tools, Macro, VisualBasicEditor)

    4. In VBE create a new module (Insert, Module) and change its name (View, Properties); save your template.


    From now on when I post a chunk of code, I'll probably say something like "This belongs in your String module" or "This is the first function for a new module called INI". If you don't understand what I'm saying, please post your question here. There are members here who CAN explain things clearly.

    My next post will assume that you've created a folder and a template.

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code: getting started

    I've found a couple of OPTION settings in VBE to be most useful.

    Tools, Options, turn OFF "auto syntax check". I do a lot of drag'n'drop editing and the auto check causes me to use more clicks than if I wasn't drag'n'dropping

    Tools, Options, turn ON "require variable declaration". This forces me to declare all identifiers. In the past, in a variety of languages, NOT declaring identifiers has caused me strife. I'm getting too old for strife .....

  3. #3
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code: getting started

    A couple of comments.

    1- You seem to be putting some of your message text inside <pre></pre>. This is causing the message text to become one very long line that we have to scroll to the right to read. The next message in this thread is one of those. I don't have any problem using <pre></pre> around program code (I do that myself), and I don't mind scrolling over to read that. Howwever, it is a real pain to have to scroll back and forth to read the message text.

    2- The message following this one seems to have the ability to reply turned off. Do you know how this was done, and more importantly WHY was it done. That makes it VERY difficult for someone to comment on or ask questions about what you posted. It also makes it very difficult for those of us that read in Threaded mode to follow what goes with what when replies are not properly threaded with what they are replying to.
    Legare Coleman

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code: getting started

    >. The next message in this thread is one of those.

    I can see what you mean, but I really think there's something weird about settings. This morning I posted, then read, then re-edited that message. This afternoon when I go to look at it there is no reply or edit button, so I'm unable to see the tags at all.


    >2- The message following this one seems to have the ability to reply turned off. Do you know how this was done, and more importantly WHY was it

    I'm sorry but I have absolutely no idea about this either.

    I'm spending far too much time trying to work out on this new board how to do what was straightforward on the old board.

    Yesterday I commented in Loumge Matters about some of my difficulties. Today, again, I've examined every one of the settings in the three edit profiles; I see nothing that suggests the nature of the problem.

    I'm beginning to think that the Lounge has established something on my system that throws it off.

    I have been making use of the "daily digest" and the replies-to-postings, and using the hyperlink in those emails to access the messages on the board.

    I think I'll just turn off every switch I can see and maybe start all over again.

    I apologize for the inconvenience this is causing to other users; it's causing just as much inconvenience, bordering on misery, to me.

  5. #5
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code: getting started

    Chris,

    >Moderator has been set the task or organising my brain

    Now THERE'S a big job!
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  6. #6
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code: getting started

    Chris,

    I've split a few of the longer lines in the code, which makes the wrapping not so bad.

    I don't know about the lack of reply. There was one for me- but you had to scroll right to see it.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  7. #7
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code: getting started

    Geoff: Ah Ha, now I see the reply button. I guess I didn't scroll right far enough.
    Legare Coleman

  8. #8
    Silver Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles, California, USA
    Posts
    1,734
    Thanks
    0
    Thanked 3 Times in 1 Post

    Re: Code: getting started

    >>using the hyperlink in those emails to access the messages on the board.

    If you do that you will lose complete track of where you are because it munges the cookies.

    You know "a poor workman blames his tools"? Learn how to use the board instead of grumbling about the "old days"!

    Could you please format your code to 60 chars wide before you paste it in - that would make like infinitely easier for all concerned.
    <IMG SRC=http://www.wopr.com/w3tuserpics/Eileen_sig.gif>

  9. #9
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code: getting started

    > If you do that you will lose complete track of where you are because it munges the cookies.


    Maybe that's what has been happening. I have since dropped all subscriptions. I thought subscriptions would be a good idea, because I'd get to see and reflect on immediate responses prior to logging on to the lounge.

    By using those hyperlinks I've felt that I've not had the mobility that other users have.

    How are other people making use of the hyperlinks in the email subscriptions anyway?



    >You know "a poor workman blames his tools"? Learn how to use the board instead of grumbling about the "old days"!

    I'm not a poor workman, and I'm not blaming the tools. I'm bemoaning the fact that **I** can't seem to understyand what's going on. One day I see REPLY buttons, the next I don't! I know that they are there and that they work. They were there a few minutes ago. If they aren't there at 8p.m. tonight, I'm confused!

    >Could you please format your code to 60 chars wide before

    I have checked my Profile settings for the third time today. It's still set as a text area 60 columns wide. The wide formatting seems to be the result of mis-placed (pre) tags.

    I would have inspected/changed the post, but that Change/Edit/delete option had disappeared, as had the Reply buttons.

    I've emailed to Geoff W a couple of BMPs so's he can see what I see when I'm on the board. It's *as if* a message display is completely blanketing an area that shouldn't be blanketed.

    Again, I've inspected my edit preferences and can see no obvious naughty setting at all.

  10. #10
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code: getting started

    I make heavy use of what we used to call compile-time variables. I was so miffed that Word6/WordBasic didn't have them. Here is a large block of common declarations that I use all over the place. You can elect to set up a module DECLS(DECLarationS) and dump them all in and never worry about them again, or you can save this code in a text file and then copy/paste a line as a procedure requires its use.

    Once you have pasted code into a DECLS module, in VBE choose Debug, Compile and make sure you got 'em all.


    Option Explicit

    ' Start of declarations
    Public Const strcApplication As String = "eraseme"
    Public Const intcBase As Integer = 256
    Public Const strcFontSeparator As String = " "
    Public Const strcCmdOK As String = "Orright!"
    Public Const strcDefaultColours As String = "0| 256| 36| 197| 251| 126| 54| 63| 195| 205| 152|"
    Public Const strcUserPath As String = "c:"
    Public Const strcLogFile As String = "LogFile"
    Public Const strcLogFileDefault As String = "logfile.txt"
    Public Const boolcDebug As Boolean = True
    Public Const intcErrorInform As Integer = 1 'Information only. e.g. "A style has been created"
    Public Const intcErrorWarn As Integer = 2 ' Warning e.g. "Document exceeded date limitations and has been bypassed"
    Public Const intcErrorSevere As Integer = 4 ' Severe e.g. "The Document was not made available to us"
    Public Const intcErrorFatal As Integer = 8 ' Fatal e.g (I cannot think of a good example from outside this module!)
    Public Const strcErrorFile As String = "EMSErrors.ini" ' generic title for section in Ini file
    Private strCodeTrans As String
    Private strStandardLog As String
    Public Const intcBFSDrive = 0
    Public Const intcBFSPath = 1
    Public Const intcBFSName = 2
    Public Const intcBFSExt = 3
    Public Const intcBFSNameExt = 4
    Public Const intcBFSDrivePath = 5
    Public Const strcColours As String = "Colours"
    Public Const strcFonts As String = "Fonts"
    Public Const strcErrorMessages As String = "ErrorMessages"
    Public Const strcINIFileDelimiter As String = "|"
    Const strcIdentifier As String = "Build" ' This will be used as the identifier of the variable
    Const intIncrement As Integer = 1 ' The variable will be incremented by this much on each call
    ' Basic RANGE CONSTRUCTION constants
    Public Const strcRangeOpen As String = "[" ' start of LIKE component
    Public Const strcRangeClose As String = "]" ' end of LIKE component
    Public Const strcRangeSeparator As String = "-" ' LIKE range separator
    ' Elements for UPPER CASE ALPHABETICS
    Public Const strcLowUpperAlpha As String = "A"
    Public Const strcHighUpperAlpha As String = "Z"
    Public Const strcUpperAlphaRange As String = strcLowUpperAlpha & strcRangeSeparator & strcHighUpperAlpha
    ' Elements for LOWER CASE ALPHABETICS
    Public Const strcLowLowerAlpha As String = "a"
    Public Const strcHighLowerAlpha As String = "z"
    Public Const strcLowerAlphaRange As String = strcLowLowerAlpha & strcRangeSeparator & strcHighLowerAlpha
    ' Elements for DIGITS
    Public Const strcLowDigit As String = "0"
    Public Const strcHighDigit As String = "9"
    Public Const strcDigitsRange As String = strcLowDigit & strcRangeSeparator & strcHighDigit
    ' Elements for COMMON RANGES
    Public Const StrcRangeLowerAlphabetics As String = strcRangeOpen & strcLowerAlphaRange & strcRangeClose
    Public Const StrcRangeUpperAlphabetics As String = strcRangeOpen & strcUpperAlphaRange & strcRangeClose
    Public Const StrcRangeAlphabetics As String = strcRangeOpen & strcUpperAlphaRange & strcLowerAlphaRange & strcRangeClose
    Public Const StrcRangeDigits As String = strcRangeOpen & strcDigitsRange & strcRangeClose
    Public Const StrcRangeAlphaNumeric As String = _
    strcRangeOpen & strcUpperAlphaRange & strcLowerAlphaRange & strcDigitsRange & strcRangeClose
    Public Const strcLowerAlpha As String = "abcdefghijklmnopqrstuvwxyz"
    Public Const strcUpperAlpha As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    Public Const strcAlpha As String = strcLowerAlpha & strcUpperAlpha
    Public Const StrcDigits As String = "0123456789"
    Public Const strcPunctuation As String = "~!@#$%^&()-_{}" ' ref: PCMag "PCDos powerTools p 32"
    Public Const intcDrive As Integer = 0 ' Returns the drive letter
    Public Const intcPath As Integer = 1 ' Returns the directory path
    Public Const intcName As Integer = 2 ' Returns the filename (without the extension)
    Public Const intcExtent As Integer = 3 ' Returns the extension
    Public Const intcFullName As Integer = 4 ' Returns the filename and extension
    Public Const intcDrivePath As Integer = 5 ' Returns the drive and path
    Public Const strcDriveSeparator As String = ":"
    Public Const strcExtentSeparator As String = "."
    Public Const strcDelimiter As String = ","
    Declare Function apiGetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" _
    (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, _
    ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
    Declare Function apiPutPrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" _
    (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpValue As String, _
    ByVal lpFileName As String) As Long
    Const PRINTER_ENUM_CONNECTIONS = &H4
    Const PRINTER_ENUM_LOCAL = &H2
    Type PRINTER_INFO_1
    Flags As Long
    pDescription As String
    pName As String
    PComment As String
    End Type
    Private Declare Function EnumPrinters Lib "winspool.drv" Alias "EnumPrintersA" _
    (ByVal Flags As Long, ByVal Name As String, ByVal Level As Long, pPrinterEnum As Long, _
    ByVal cdBuf As Long, pcbNeeded As Long, pcReturned As Long) As Long
    Private Declare Function PtrToStr Lib "kernel32" Alias "lstrcpyA" (ByVal retval As String, ByVal Ptr As Long) As Long
    Private Declare Function StrLen Lib "kernel32" Alias "lstrlenA" (ByVal Ptr As Long) As Long
    ' End of declarations

  11. #11
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code: getting started

    A post from Geoff W suggested I scroll right. i did, and waaay off to the right were the buttons. I edited the post. The (pre) tag was immediately before the declarations code, and there was no evidence of the (pre) tagging before the short text that preceded the declarations.

    I removed all references to pre and not-pre and resubmitted the post.

    I hope it is OK now. I'll avoid using pre- for the time being.


    Does the scroll-right fix the other problem you mentioned - being locked out of replying? It seems to be a likely explanation for me.

  12. #12
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code: getting started

    >I don't know about the lack of reply. There was one for me- but you had to scroll right to see it.

    Thanks, Geoff. I've found that now.

    The original problems all seem to stem from my use of pre-tags. I'll avoid them for the time being.

  13. #13
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code: getting started

    Chris,

    Pre tags are good for code, as they preserve the formatting.

    However, when they're used, as well as the wide lines, you can't copy directly into the VBA editor- soft returns a re used, and they're not pasted into VBA.

    So what might be a good compromise is to put the code into a TXT file, and attach it to the message- I've attached your "strOnly" code as an example.
    Attached Files Attached Files
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  14. #14
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code: getting started

    Chris,

    Is there a reason for using api calls for privateProfileString, as opposed to VBA's "PrivateProfileString"?
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  15. #15
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code: getting started

    >I have made one called WOODY, and used good Manjimup jarrah (that's a joke for Geoff)

    That's a Western Austrlian tree- very good quality wood.

    Maybe that wooden work?
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

Page 1 of 2 12 LastLast

Posting Permissions

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