Page 2 of 4 FirstFirst 1234 LastLast
Results 41 to 80 of 144

Thread: [RESOLVED] Runtime error '91': Object variable or with block not set

  1. #41

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    I love the select case statement. Poses less trouble for me. Thank you.

  2. #42

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Yeah it is a nice day. Thanks for that and truly need to go catch some fun.

  3. #43

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    MartinLiss, your option button proved such a powerful tool. Infact I applied it to my combo box of "uncoated" and "coated" and it was so powerful. Thank you for the knowledge. Cheers

  4. #44

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Hi martinLiss, Please what can you make out from this unwelcomed visitor to my app? Each of the lines
    Code:
    "Case "Deep groundbed""
    that is supposed to be executed by the command pops unexpected value. It has been working fine. Don't know what has gone wrong with that frame. Please help. Thanks
    Attached Files Attached Files

  5. #45
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Your problem is similar to the one we resolved before where you had a space at the end of the text in the combobox. Do a Ctrl-F to find the first occurrence of "Deep groundbed" and click Find Next to find the next one, etcetera. When you find any that say "Deep groundbed " change them to "Deep groundbed". Another, easier, way would be to do Ctrl-H and Replace All "Deep groundbed " to "Deep groundbed".

    BTW I just noticed that in several places you do Dim <nameofform> As Form. It doesn't hurt you but there is no need to do that.

    Also I noticed several things about your combo boxes:

    1. The right side of cboorientation is hidden under cmdcancelform and you should change that.
    2. In a couple of places you still have cboorientation.clear and that will cause you problems unless you fix that.
    2. In cmdcalculate_Click you have the following code

    Code:
    If TypeOf Ctl Is ComboBox Then
       If Ctl.Visible = True And Ctl.Text = "" Then
          MsgBox "No Box Should Be Left Empty"
         Ctl.SetFocus
         Exit Sub
      End If
    End If
    which doesn't do you any good because the way you have your comboboxes set up (Style = 0) a user can type in anything they want and are not limited to your choices. Also since (I assume) you added the 'Select' text after you added the above code, the likelihood that the text will be blank is small. Here is what I would do. I would change all the styles to 2 and then instead of checking for Ctl.Text = "" I would check for Ctl.ListIndex = -1 and change the error message to "Please make a selection". If you aren't aware, a ListIndex of -1 says nothing has been selected and a ListIndex of 0 says the first item has been selected.

    If you want to get into it there are several other things that you could do to that IMO would improve your program.

  6. #46

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Thanks MartinLiss, Thought I got those clear instructions wiped out before posting across? Proving stubborn to really get rid of. What is IMO? Please detail me the infor so that I get a knowledge of it. Cheers

  7. #47

  8. #48

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Thanks MartinLiss, that's a load of information and very grateful.

  9. #49

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Ok i get it, thanks.

  10. #50

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Thank you MartinLiss, unwanted visitor(bug) has been thrown of my app. Very grateful for the impactation of knowledge.

  11. #51

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    I thought putting the combo and the cmdcancelform at the same co-ordinate was a great idea cz at run time it's default is Visible = False. On an event method it becomes true making visible while cmdcancelform becomes False. Should I change it?

  12. #52
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Quote Originally Posted by Ehwenomare View Post
    I thought putting the combo and the cmdcancelform at the same co-ordinate was a great idea cz at run time it's default is Visible = False. On an event method it becomes true making visible while cmdcancelform becomes False. Should I change it?
    I don't know. Is there a problem with the way you are doing it?

  13. #53
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    You didn't say yes or no in response to my suggestion in the last line of post #45 but here is what I have so far.

    In no particular order

    1. You should compile your program. When you do you'll find that you have several errors including missing 'End If' statements in designdrivingvoltage() and spacingfactor()

    2. You have Const Pi = 3.142 in a lot of places. If you add a code module to your project you can add Public Const Pi = 3.142 at the top of it and eliminate all the rest.

    3. You name everything in all lower case and that's not a good idea for two reasons. 1) it makes the names harder to read. For example actualendoflifecurrent is a lot harder to read than ActualEndOfLifeCurrent, and 2) If you used ActualEndOfLifeCurrent and you typed actualenoflifecurrent (no 'd') by mistake, VB would leave it that way and you'd know you typed it wrong, but if you typed actualendoflifecurrent, VB would change it to ActualEndOfLifeCurrent and you'd know it was right. If you decide you want to do that you can 'mass change' all the occurrences of any given name using Ctrl-h, but that wouid be a massive effort in your current project. BTW note that the suffix of control names is usually kept lower case so txtCoatingResist and not TxtCoatingResist.

    4. You should correct the tab order of your controls so that hitting the Tab key allows the user to progress in an orderly fashion. You do that by changing the TabIndex of the controls. That can be messy to do because if you want to change a given control's TabIndex from, say, 2 to 5 and 5 already exists, you need to change 5 to something else (which could be 99) temporarily. MZ-Tools, an extremely useful addin that you can download for free from the web, includes a TabAssistant that makes the job easier.

    5. I find the black text on dark blue background of your two output forms very hard to read.

    6. The BorderStyle of your forms are 2 - Sizable and IMO they should be 1 - Fixed Single. As it is now I can drag down the lower edge of the offshorecpsystems form and expose the Calculate button prematurely.

    7. Currently a user can enter negative numbers in your textboxes and pass your validations. You should check for that and I also assume that certain textboxes have maximum allowable (at least reasonable) values and you should check for those as well.

    8. You have a lot of textboxes on your forms and even though you SetFocus to them when there's an error, it's hard to find the textbox with the blinking cursor. One possibility to fix that would be to add the following Sub to a code module and change the several 'ctl.SetFous' lines in cmdcalculate to 'Flash' or 'Call Flash'.

    Code:
    Public Sub Flash(ctl As Control)
    
        Dim dblClock As Double
        Dim lngCount As Long
        
        For lngCount = 1 To 6 ' If you change the 6, make sure it's an even number
            dblClock = Timer
            
            ' Pause .25 seconds
            While Timer < dblClock + 0.25
                DoEvents
            Wend
            ctl.Visible = Not ctl.Visible
        Next
        
        ctl.SetFocus
        
    End Sub

  14. #54

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    This line of the code is giving run time error 438:Oject doesn't support property or method after changing the Ctl.Clear to that
    vb Code:
    1. If Ctl.Visible = True And Ctl.ListIndex = -1 Then

  15. #55
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Quote Originally Posted by Ehwenomare View Post
    This line of the code is giving run time error 438:Oject doesn't support property or method after changing the Ctl.Clear to that
    vb Code:
    1. If Ctl.Visible = True And Ctl.ListIndex = -1 Then
    I'm not sure why you did that. Only comboboxes and listboxes have ListIndex properties so I assume that CTl at that point isn't one of those two types. Also my suggestion for using ListIndex = -1 was meant only to tell if the user had made a selection or not.

  16. #56

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Ok, I'll fix that now but finding real hard to digest post 53: numbers 4 and 8 I guess. Thanks

  17. #57

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    For number 5 plan to do a rework later tonight on the app by changing that blue color to the default color.

  18. #58

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Ok, number 8 just became clearer. Thanks

  19. #59

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    What can this
    vb Code:
    1. For lngCount = 1 To 6
    line represent in my current code?

  20. #60
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Quote Originally Posted by Ehwenomare View Post
    Ok, I'll fix that now but finding real hard to digest post 53: numbers 4 and 8 I guess. Thanks
    Number 4: Start your app and choose offshore. Enter something for 'Pipe diameter' and press the Tab key. That sends you to the initial Coating Breakdown Factor' which is sort of okay but after that continuing to press the Tab key sends you all over the place rather than right to left, top to bottom which is normal for professional apps. It's the TabIndex property that controls where the cursor goes after Tab is pressed so they should be change so that
    txtpipediameter = 0
    txtpipelength = 1
    txtcoatingbrkfac = 2
    txtcoatingresist = 3
    txtenvironmentalresist = 4
    etcetera

    The TabIndex of the first control doesn't have to be 0, but the numbers should be in ascending sequence.

  21. #61
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Quote Originally Posted by Ehwenomare View Post
    What can this
    vb Code:
    1. For lngCount = 1 To 6
    line represent in my current code?
    It is just a counter that I added to my Flash Sub that blinks the control 3 times. If 6 is changed to 8 it would blink 4 times, etc.

  22. #62

  23. #63

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Lol. I get it now. O! yeah that thing. very annoying when I first noticed it but never knew how to change rather just deleting the controls and starting all over. Thanks

  24. #64

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Ok. Thanks

  25. #65

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Ok. I get it now. Let me give it a try. Thanks for the option button. Offshore app looks excellent. I wish I had enough space it would have been option button all the way.

  26. #66

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    I tried number 8 but it gave me a compile error of argument not optional. How do I fix that?

  27. #67

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Here is what I did:
    Code:
    Private Sub cmdcalculate_Click()
        Dim ctl As Control
        For Each ctl In Me.Controls
            If TypeOf ctl Is TextBox Then
                If ctl.Visible = True And ctl.Text = "" Then
                    MsgBox "Please make a selection"
                    Flash
                    Exit Sub
                End If
                If Not IsNumeric(ctl.Text) And ctl.Visible = True Then
                    MsgBox "You must enter numeric value"
                    Flash
                    Exit Sub
                End If
            End If
            If TypeOf ctl Is ComboBox Then
                If ctl.Visible = True And ctl.ListIndex = -1 Then
                    MsgBox "Please make a selection"
                    Exit Sub
                End If
            End If
        Next ctl

  28. #68
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Quote Originally Posted by Ehwenomare View Post
    Ok. I get it now. Let me give it a try. Thanks for the option button. Offshore app looks excellent. I wish I had enough space it would have been option button all the way.
    You have all the room you need. try the little app I attached that contains 5 frames that all together could hold many controls. Note that there is a limit of 255 controls allowed per form, but for the sake of the 255 count, all the members of a control array together count as just 1 control.
    Attached Files Attached Files

  29. #69
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Quote Originally Posted by Ehwenomare View Post
    Here is what I did:
    Code:
    Private Sub cmdcalculate_Click()
        Dim ctl As Control
        For Each ctl In Me.Controls
            If TypeOf ctl Is TextBox Then
                If ctl.Visible = True And ctl.Text = "" Then
                    MsgBox "Please make a selection"
                    Flash
                    Exit Sub
                End If
                If Not IsNumeric(ctl.Text) And ctl.Visible = True Then
                    MsgBox "You must enter numeric value"
                    Flash
                    Exit Sub
                End If
            End If
            If TypeOf ctl Is ComboBox Then
                If ctl.Visible = True And ctl.ListIndex = -1 Then
                    MsgBox "Please make a selection"
                    Exit Sub
                End If
            End If
        Next ctl
    Sorry but in my description in #8 I made a mistake in my directions but it's one that you could have probably figured out. Look at the Flash Sub. From its heading you see that it needs a parameter which is the control to flash, so where you put 'Flash' in your code change it to 'Flash Ctl'.

  30. #70

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Interesting!

  31. #71

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Thank you MartinLiss. Very grateful. Number 8 is working. Let me take a look at number 4. I will miss you. Maybe should start another app. Very best wishes dear friend. I'll keep you posted. Thank you and good night.

  32. #72

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Hi MartinLiss. Thank you for the MZ-Tools. It worked on my app. Now my app looks very professional. Thanks and cheers.

  33. #73
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    When you're happy with your app, attach it again and I'll make you unhappy. Just joking but I'll be happy to review/test it again at any time If you do post it again please include the complete project in the rar.

  34. #74

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Lol. I will but will it be in the forum and somewhere private?

  35. #75

  36. #76

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    You mean here? or your private box?

  37. #77

  38. #78

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Ok. No objections. Will be done once I finish doing the overhauling.

  39. #79
    New Member
    Join Date
    Jul 2011
    Posts
    1

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    In no particular order

    1. You should compile your program. When you do you'll find that you have several errors including missing 'End If' statements in designdrivingvoltage() and spacingfactor()

    2. You have Const Pi = 3.142 in a lot of places. If you add a code module to your project you can add Public Const Pi = 3.142 at the top of it and eliminate all the rest.

    3. You name everything in all lower case and that's not a good idea for two reasons. 1) it makes the names harder to read. For example actualendoflifecurrent is a lot harder to read than ActualEndOfLifeCurrent, and 2) If you used ActualEndOfLifeCurrent and you typed actualenoflifecurrent (no 'd') by mistake, VB would leave it that way and you'd know you typed it wrong, but if you typed actualendoflifecurrent, VB would change it to ActualEndOfLifeCurrent and you'd know it was right. If you decide you want to do that you can 'mass change' all the occurrences of any given name using Ctrl-h, but that wouid be a massive effort in your current project. BTW note that the suffix of control names is usually kept lower case so txtCoatingResist and not TxtCoatingResist.

    4. You should correct the tab order of your controls so that hitting the Tab key allows the user to progress in an orderly fashion. You do that by changing the TabIndex of the controls. That can be messy to do because if you want to change a given control's TabIndex from, say, 2 to 5 and 5 already exists, you need to change 5 to something else (which could be 99) temporarily. MZ-Tools, an extremely useful addin that you can download for free from the web, includes a TabAssistant that makes the job easier.

  40. #80

    Thread Starter
    Addicted Member
    Join Date
    Jul 2011
    Posts
    139

    Re: [RESOLVED] Runtime error '91': Object variable or with block not set

    Hi MartinLiss, when you said the complete project, do mean the paper work should also be included. Could you clarify what you mean by the complete project? Cheers

Page 2 of 4 FirstFirst 1234 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
  •  



Click Here to Expand Forum to Full Width