Consulting

Page 3 of 3 FirstFirst 1 2 3
Results 41 to 50 of 50

Thread: Global StrConv function?

  1. #41
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    TabIndex has nothing to do with it, BUT....you can use the TabIndex to make a new array and get your message in the user tab order. That is, in the order the user will tab through the userform. Which, I believe, is what you want to happen Cheryl. I am tempted to just give textual descriptions and hints...but, nah.....

    Sample (simple) demo file attached. Fire the userform with the "Show My Form" icon on the top toolbar.

    Enter something in some of the textboxes. Click "Check It". The userform expands to display three messages in Labels.

    The first lists any empty control by control index. This is the order For Each ctl In Me.Controls produces.

    The second is the list of empty controls sorted by TabIndex (the order the user moves through the userform). This uses a version of the BubbleSort procedure xld posted in the knowledge base.

    The third message is the list of empty controls by name, also in the TabIndex (user movement) order.

    If you look in the code, it requires a HARD coding of all the controls you may wish to name. It only needs names of the controls the user actually uses. Labels and command buttons are not required, as they are ignored by the checking logic anyway.

    So while true, the original error checking (to get the controls that are empty) has nothing to do with TabIndex, TabIndex values ARE used to determine how the control names are displayed.

    There are other possible routes to take to achieve this.

    I will repeat something I mentioned earlier. Solid error trapping is BY FAR the hardest work in coding an application. Hopefully you all will be a bit more patient when you come across screwy things in major applications (like Word for example). Catching stuff is HARD.

    I will repeat another mention. I did a VBA app that took 500 lines of code to make the whole thing "work"....and 3,000 lines of code to error trap it as tight as possible. Most apps do not require that level of accuracy. This one did. I would not like to repeat the experience. The coding parts was not that difficult, but the THINKING part was a major headache.

    If you look at the code in the file attached, it is not very difficult at all. And I freely admit it can likely be made tighter and better. I just put it together this evening as a demo for you whiners. Just kidding Cheryl. I know it is hard. Believe me, I know.

    Hope this helps. It is as far as I am going to go with this. It of course can be expanded to cover ANY control on your userform. You just have to think about it.

    I would strongly recommend you do NOT, repeat NOT, do a copy and paste of the code. Write your own. Copy and paste if you must, but go through each line, line by line and make it yours.

    Oh, BTW....just so you know I can be an idiot - although I suppose that is already quite apparent - here is a laugh.

    I had finished this demo, placed the controls, juggled them around so they would deliberately NOT match user Tab movement to control index. Wrote the code for the userform, wriggled xld's BubbleSort (his uses Option Base 1, and that just screws me up), changed some variables (I needed an number sort, not a string sort).

    I decided that I wanted to change the textbox names. I had them as "TabMeOne", "TabMeTwo" etc, to show the user movement order. Then thought, what the heck...why not use real world names like FirstName, LastName etc.

    So I blithely change the control name to First Name, and quickly went on to the next control.

    Note that: First Name.

    Control names can NOT have spaces.

    The VBE gave an error message. Invalid name.

    BUT.....I had clicked so fast to the next control that the control giving the error was no longer the active control. Totally froze. The error message on screen with a lovely cursor like a Do Not Enter (a circle with a line through it). Frozen shut. The VBE was displaying a message from a control it no longer had access to.

    Enter did nothing. Clicking OK on the error message did nothing. Completely frozen. I tried everything. I could NOT get back in. I had to kill Word with Task Manager.

    I....ummmmm, had not saved anything. I lost EVERYTHING. I had to restart Word and begin right from the beginning with a new document. Make a new userform, write all the code again from scratch. No copy and paste. From scratch, including placing the textboxes, the commandbuttons etc.

    Idiot.

    My point (besides the usual SAVE IT warning) is that I timed myself. From zero, zip, nada, to the attached file.....21 minutes.

    This is not a show off thing. It is - again - a statement that coding is the minor part of things. I had the logic fully worked out. I knew EXACTLY, precisely, how it was to work, and how it was supposed to flow. I did not have to think about it the second time, because I already knew what was supposed to be there.

    Although, again, because this is VBA, there are very likely better ways of doing this. I can think of an alternative myself.

    Cheryl, and SOS, I really hope this helps you get moving along regarding this. It is likely not a full solution for your precise userform, but the principle should be (I hope!!!) adequately demonstrated.

    I'm tired.

  2. #42
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location
    I've read it a bunch of times. If tabindex has nothing to do with it, how can I change the order of the controls in the message box????

    I can't figure it out!

  3. #43
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    PS. northernstar, if you are cruising through the threads, and see this one, you may want to take a look. There is quite a bit of array use involved.

  4. #44
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Take a look Cheryl. Get back to me. While the demo does not give a messagebox - it displays the errors right on the userform via a Label - it could very easily be adjusted to give it in a messagebox.

  5. #45
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location
    This demo is fantastic! I will look at the code very carefully! Also, I never just cut and paste the code into my template. I always look at each line and try to understand exactly what the code is doing and why, then add comments throughout so I can understand it any time I go back to it. I want to learn as much as I can!

    I spend a ton of time trying to figure out how to prevent errors, especially since I have no "VBA training"--just learning as I go. There is nothing worse than working through something and locking up before it's saved--I HATE that!!!

    This forum rocks! I've learned so much from you guys! Thank you, thank you, thank you!!!!!

  6. #46
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    especially since I have no "VBA training"--just learning as I go.
    That is the situation for most (if not all) of us.

    I am completely self-taught, with lots of stuff gained from these forums. There is no training for VBA for the most part. That is why I am writing a Word VBA course, so I can actually teach.

    I like it that questions posed here sometimes challenge me to figure things out. That makes me keep learning.

    I have read a number of your posts Cheryl. You do very well for yourself. Hopefully you will get to the point where you are a teacher yourself, with others learning from YOU.

    I am happy you found the demo helpful.

  7. #47
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location
    Wow! I wish I knew as much as you about this stuff! This forum is my main source of information. I've learned so much from asking questions here and applying what I've learned as I try to do other things.

    I'm always searching the internet for VBA tutorials as well. Maybe one of these days I'll find yours!

  8. #48
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    I doubt if my course will get on the 'Net. It is going to be for a actual five day intensive classroom course. On my test run of a shortened two day version, it was hard to screen people.

    I set some pre-requisites - some reading beforehand. I supplied the reading content. I also clearly stated some knowledge pre-requisites. I was NOT going to teach anything about using Option Explicit, or declaring variables (although I do quickly re-iterate things about scope).

    I was NOT going to teach about basic uses of the VBE.

    It was a disaster. No one did any of the reading. The skill level of the people that were sent to me was essentially zero, with no knowledge of...well, anything.

    They were not even moderately skilled at Word.

    I had clearly stated to the powers-that-be that this was a abbreviated test run of a course for moderate to advanced Word users. That it was decidedly focused on design, and thinking, and understanding concepts.

    Yes I did cover things like logic statements, but I was basing my timing on being able to go through a For Each statement in....oh, 1 to 2 minutes.

    It took me 20 minutes to get them to fully understand the concept of:[vba]Dim oPara As Paragraph
    For Each oPara In ActiveDocument.Paragraphs[/vba]

    That was just one thing. My timing was screwed. I planned on going through four of my course modules in the test run two days. I could barely get through two of them.

    I mean I had to explain how to navigate through folders to get to a file! Sheeesh.

    I suppose I could write a second course more for beginners, but it is not my intention to do so.

  9. #49
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Wow! I wish I knew as much as you about this stuff!
    I wish I knew as much as Tony Jollans...so there you go. It is all relative. You are persistent, and you are (it seems anyway) not afraid to try and work it.

    That, and time, is what it takes. You will get there.

  10. #50
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Why, thank you Gerry

    What I really know is just enough to enable me to find out what I want to know.

    I am certainly still learning - in fact that is what really drives me on. Once upon a time, when I started in computers, I had this crazy idea that if I tried hard enough I could learn it all; now I know I can't even learn it all about Word - not that it stops me trying
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

Posting Permissions

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