VB6 debugging- doesn't go to error handling code - dll

I'm maintaining a vb6 project(ActiveX DLL). When debugging, the app run into the following function:
Public Function HasValue(ByVal vValue) As Boolean
On Error GoTo Err
If IsMissing(vValue) Then
HasValue = False
ElseIf IsNull(vValue) Or Len(vValue) = 0 Then
HasValue = False
ElseIf isEmpty(vValue) Then
HasValue = False
Else
HasValue = True
End If
Exit Function
Err:
If IsArray(vValue) Or IsObject(vValue) Then
HasValue = True
Else
HasValue = False
End If
End Function
and it stops at the line
ElseIf IsNull(vValue) Or Len(vValue) = 0 Then
vValue is a custom object, contains some properties(obviously, not null).
Although I didn't put any break point there, the app stopped there and alerted error dialog saying that "Run-time error '438': Object doesn't support this property or method".
We had error handling code but the app didn't run to error handling code. It just stopped at the line causing the error and I had to stop the application.
Do you have any idea about that?
Thank you very much.

As far as getting the popup running in the debugger, it is probably related to your "Error Trapping" settings in the IDE. Go To Tools->Options->General and see what selected under "Error Trapping". At first glance it seems odd that your error handler is testing the vValue in the event of an error. It makes more sense to me based on my limited understanding of this method to move both the IsArray and IsObject conditions up into the main testing logic. Just my 2 cents :)

As far as i know vb6 does not support boolean short evaluation in
ElseIf IsNull(vValue) Or Len(vValue) = 0 Then
so Len(vValue) = 0 is executed even if IsNull(vValue) is true.
changing your code to
...
ElseIf IsNull(vValue) Then
HasValue = False
ElseIf Len(vValue) = 0 Then
HasValue = False
ElseIf ...
might solve the problem

Related

jump if findelementbypartialtext=false

how do I make it so that if there is no link to click on because it is not found it continues to jump?
if GC.FindElementByPartialLinkText("CANTFINDTHIS") =false
MsgBox ("false")
else
MsgBox ("true")
end if
i get
Runtime error 438: Object doesn't support this property or method
somehow there is a true false in the boolean but i haven't figured out how to use it yet
Function FindElementByPartialLinkText(partiallinktext As String, [timeout As Long = -1], [raise As Boolean = True])

ListSubItems - Method or Data Member not found

I am getting the error "Method or Data Member not found" for ListSubItems whenever I try to compile the project. I have added the SP6 component, MSCOMCTL.OCX. But still I am getting this error.
Public Function SetBoldToListItemInListView(lv As ListView, lvwItem As ListItem, bBold As Boolean) As Boolean
Dim i As Integer
On Error GoTo EH
ResetBoldInListView Not bBold, lv
lvwItem.EnsureVisible
For i = 1 To lvwItem.ListSubItems.Count
lvwItem.ListSubItems(i).Bold = True
Next
lvwItem.Bold = True
lvwItem.Selected = True
lv.Refresh
SetBoldToListItemInListView = True
ExitProc:
On Error Resume Next
Exit Function
EH:
Error_Handler "Support / CheckUncheckItemsInListView"
Resume ExitProc
End Function
This is an old question but for anyone still looking for an answer you need to add a component Microsoft Windows Common Controls 6.0 (SP6).
Go to Projects -> Components (Ctrl+ T) and check the checkbox for it.
Once this is added, you will also see extra components in the available GUI elements.

Can't find a library or function - Visual Basic 6

I am a newbie in visual basic, when i tried to run this code,the above error pops up.I have declared an user defined function named initiative but for no reason the error pops up.
Private Sub initiate()
For i = 0 To 2
COURSE(i).Value = False
SEM(i).Value = False
If i <> 2 Then
ODDEVEN(i).Value = False
End If
Any help is appreciated.

mshtml.IHTMLDocument returning nothing

I have the below code trying to access a webpage and the program is erroring out at a test for the innerHTML property. Below is the code:
iex = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")
iex.visible = True
iex.navigate("https://url.aspx")
While iex.readystate <> 4 Or iex.busy
Application.DoEvents()
End While
Dim htdoc As mshtml.IHTMLDocument = iex.Document
Dim htstring As mshtml.IHTMLBodyElement = htdoc.body
If (InStr(htstring.innerHTML, "An error occured while processing your request") > 0) Then
The last line is where it gets the error. And I have determined that it gets the error because htdoc is nothing, resulting in everything else being nothing. At least, that is what I believe the issue to be.
After further troubleshooting, the below line is what is causing the error.
mshtml.IHTMLBodyElement = htdoc.body
The exception error is:
Message = Exception from HRESULT: 0x800A01B6
Item = In order to evaluate an indexed
property, the property must be qualified and the arguments must be
explicitly supplied by the user.
This was working before IE was updated to IE11 (I don't recall what version it was prior, but I would assume it was IE10).
I don't think I am doing anything wrong, but any help you could provide would be greatly beneficial!

Return Error on "function returning intrinsic value type without return value" with CodeDOM

When compiling VB.NET code, by default the compiler does not give error notification if a function is not returning a value.
You can change this under the project's compiler options to return error on "function returning intrinsic value type without return value".
Just wondering is it possible to achieve the same with the CodeDOM class using VBCodeProvider?
Dim provider As New Microsoft.VisualBasic.VBCodeProvider
Dim params As New CompilerParameters
Dim results As CompilerResults
With params
.GenerateExecutable = False
.GenerateInMemory = True
.IncludeDebugInformation = False
End With
'Compile
results = Provider.CompileAssemblyFromSource(params, Source)
Return results
You can specify error control via CompilerParams:
With params
.GenerateExecutable = False
.GenerateInMemory = True
.IncludeDebugInformation = False
' add:
.WarningLevel = 4
.TreatWarningsAsErrors = True
End With
The WarningLevel relates to that setting in the C# Compile tab option, but there is not a lot of documentation on it for CodeDOM. Those would be the most strict settings, so the one you are interested in should be there.