Namespace Ignoring Empty String Values (URGENT)

  • Thread starter Thread starter scorpion53061
  • Start date Start date
S

scorpion53061

I have little hope of resolving this as I have had to contact outside
help.

But I thought I would post it here to see if anyone could add an idea or
solution.

1. I have a form in a Class Control library along with 6 other
namespaces. My root functions are in this form and all the other
namespaces revolve around this form. I add the project as a dll to
another windows project and call its functions there. Option Strict is
on.

2. I compile as a dll and add it to another project.

3. I access the same instance of the form in this dll like this:

Private Shared arrgen As
ArraySoftware.ArrayGeneralNamespace.ArrayGeneral
Public Shared Function getInstance() As
ArraySoftware.ArrayGeneralNamespace.ArrayGeneral
ArraySoftware.ArrayGeneralNamespace.ArrayGeneral
Return arrgen
End Function

4. I have a property in another namespace that is called ItemPrice2 of
the type string. It looks like this:

Private itpr2 As String
Public Property ItemNumberPrice2() As String
Get
Return itpr2
End Get
Set(ByVal Value As String)
itpr2 = Value.ToString
End Set
End Property


5. In the past when the varaible was local to the project and not in a
dll I could say

If ItemPrice2 = "" Then

'perform this action

End If

However if I attempt to do this I get an invalid cast error in this
function.

If on the chance something is present in the string then it works. But
if there isn't then I get the invalid cast errors.

When I step through it appears the value of the screencontents variable
is changed if the string is empty. Does anyone have ideas on how I might
resolve this?

System.InvalidCastException: Cast from string "The program 'app.exe' has
exited with code 0 (0x0).

Function ItemNumberGetPrice2() As Boolean
ItemNumberPrice2 = ""
Try
If ItemNumberNotPriced = True Then
ItemNumberPrice2 = "0.00"
ItemNumberPrice2 = Format(CDbl(ItemNumberPrice3),
"$##0.##0")
Return True
End If
Catch ex As Exception

ArraySoftware.ArrayGeneralNamespace.ArrayGeneral.getInstance.getInstance.ArrayErrorScreenContents
= "Error Code MBS802-16 " & ex.ToString

ArraySoftware.ArrayGeneralNamespace.ArrayGeneral.getInstance.getInstance.ArrayErrorGetMainMenu()
Return False
End Try


ArraySoftware.ArrayGeneralNamespace.ArrayGeneral.getInstance.getInstance.LabelStatus.Text
= "Getting Second Price..."

ArraySoftware.ArrayGeneralNamespace.ArrayGeneral.getInstance.getInstance.LabelStatus.Refresh()

ArraySoftware.ArrayGeneralNamespace.ArrayGeneral.getInstance.getInstance.ScreenX
= 6 'x coordinate in text being read

ArraySoftware.ArrayGeneralNamespace.ArrayGeneral.getInstance.getInstance.ScreenY
= 18 'y coordinate

ArraySoftware.ArrayGeneralNamespace.ArrayGeneral.getInstance.getInstance.ScreenL
= 10 'length of text in text being read

Try

ArraySoftware.ArrayGeneralNamespace.ArrayGeneral.getInstance.getInstance.ScreenInformationGet()
ItemNumberPrice2 =
ArraySoftware.ArrayGeneralNamespace.ArrayGeneral.getInstance.getInstance.ScreenContents
'Trace.WriteLine(String.Format("{0} {1}",
ItemNumberPrice2, ItemNumberPrice2.Length))

'THIS IF ... END IF SECTION IGNORED WHEN STRING IS EMPTY....

If ItemNumberPrice2.Length < 1 Or ItemNumberPrice2 = ""
Or ItemNumberPrice2 = String.Empty Or ItemNumberPrice2 Is Nothing Or
ItemNumberPrice2 = "0" Then
MsgBox("WE are here")
ArraySoftware.ArrayGeneralNamespace.ArrayGeneral.getInstance.getInstance.LabelStatus.Text
= "No second price.."

ArraySoftware.ArrayGeneralNamespace.ArrayGeneral.getInstance.getInstance.LabelStatus.Refresh()
ItemNumberNotPricedPrice2 = True
ItemNumberPrice2 = "0.00"
ItemNumberPrice2 = Format(CDbl(ItemNumberPrice2),
"$##0.##0")
Return True
Exit Function
End If
If CDbl(ItemNumberPrice2) > 9999 Then

ArraySoftware.ArrayGeneralNamespace.ArrayGeneral.getInstance.getInstance.LabelStatus.Text
= "No second price.."

ArraySoftware.ArrayGeneralNamespace.ArrayGeneral.getInstance.getInstance.LabelStatus.Refresh()
ItemNumberNotPricedPrice2 = True
ItemNumberPrice2 = "0.00"
ItemNumberPrice2 =
Format(CDbl(ItemNumberPrice2.ToString), "$##0.##0")
Return True
Exit Function
End If
If CDbl(ItemNumberPrice2.ToString) = 0 Then

ArraySoftware.ArrayGeneralNamespace.ArrayGeneral.getInstance.getInstance.LabelStatus.Text
= "No second price.."

ArraySoftware.ArrayGeneralNamespace.ArrayGeneral.getInstance.getInstance.LabelStatus.Refresh()
ItemNumberNotPricedPrice2 = True
ItemNumberPrice2 = "0.00"
ItemNumberPrice2 =
Format(CDbl(ItemNumberPrice2.ToString), "$##0.##0")
Return True
Exit Function
End If
ItemNumberNotPricedPrice2 = False
ItemNumberPrice2 =
Format(CDbl(ItemNumberPrice2.ToString), "$##0.##0")
Return True
Catch ex As Exception
MsgBox(ItemNumberPrice2.ToString)
Debug.WriteLine(ex.ToString & " " &
ItemNumberPrice2.ToString)

ArraySoftware.ArrayGeneralNamespace.ArrayGeneral.getInstance.getInstance.ArrayErrorScreenContents
= "Error Code MBS802-17 " & ex.ToString

ArraySoftware.ArrayGeneralNamespace.ArrayGeneral.getInstance.getInstance.ArrayErrorGetMainMenu()
Return False
End Try

End Function

(The weird thing is I never have the words "The program" in the project.

Kelly Martens
http://www.kjmsolutions.com
(e-mail address removed)
 
Hi,

Why don’t you use a regex to see if it is a valid number instead of an
empty string?

Dim regNumber As New
System.Text.RegularExpressions.Regex("(^\d*\.?\d*[1-9]+\d*$)|(^[1-9]+\d*\.\d*$)")

If Not regNumber.IsMatch("") Then
MessageBox.Show("Not a good price")
End If

If regNumber.IsMatch("1245.455") Then MessageBox.Show("Good
number")

Ken
-------------
 
Back
Top