-
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.
-
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.
-
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
-
1 Attachment(s)
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
-
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.
-
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
-
Re: [RESOLVED] Runtime error '91': Object variable or with block not set
In My Opinion
related is IMHO In My Humble Opinion which is often used sarcastically.
-
Re: [RESOLVED] Runtime error '91': Object variable or with block not set
Thanks MartinLiss, that's a load of information and very grateful.
-
Re: [RESOLVED] Runtime error '91': Object variable or with block not set
-
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.
-
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?
-
Re: [RESOLVED] Runtime error '91': Object variable or with block not set
Quote:
Originally Posted by
Ehwenomare
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?
-
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
-
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:
If Ctl.Visible = True And Ctl.ListIndex = -1 Then
-
Re: [RESOLVED] Runtime error '91': Object variable or with block not set
Quote:
Originally Posted by
Ehwenomare
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:
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.
-
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
-
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.
-
Re: [RESOLVED] Runtime error '91': Object variable or with block not set
Ok, number 8 just became clearer. Thanks
-
Re: [RESOLVED] Runtime error '91': Object variable or with block not set
What can this line represent in my current code?
-
Re: [RESOLVED] Runtime error '91': Object variable or with block not set
Quote:
Originally Posted by
Ehwenomare
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.
-
Re: [RESOLVED] Runtime error '91': Object variable or with block not set
Quote:
Originally Posted by
Ehwenomare
What can this
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.
-
Re: [RESOLVED] Runtime error '91': Object variable or with block not set
Here is a link to MZ-Tools. It's an invaluable addition to VB6. Read about it and then decide if you want to use it.
-
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
-
Re: [RESOLVED] Runtime error '91': Object variable or with block not set
-
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.
-
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?
-
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
-
1 Attachment(s)
Re: [RESOLVED] Runtime error '91': Object variable or with block not set
Quote:
Originally Posted by
Ehwenomare
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.
-
Re: [RESOLVED] Runtime error '91': Object variable or with block not set
Quote:
Originally Posted by
Ehwenomare
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'.
-
Re: [RESOLVED] Runtime error '91': Object variable or with block not set
-
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.
-
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.
-
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.
-
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?
-
Re: [RESOLVED] Runtime error '91': Object variable or with block not set
-
Re: [RESOLVED] Runtime error '91': Object variable or with block not set
You mean here? or your private box?
-
Re: [RESOLVED] Runtime error '91': Object variable or with block not set
-
Re: [RESOLVED] Runtime error '91': Object variable or with block not set
Ok. No objections. Will be done once I finish doing the overhauling.
-
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.
-
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