BrowseDialog SearchFieldItem and the BuildWhereElement method


Author
Message
Robin J Giltner
Robin J Giltner
StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)
Group: Forum Members
Posts: 105, Visits: 650
Awesome, thanks Ben.

Robin Giltner

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
The TryParse will work, but that method will return a True/False to indicate whether the value was properly parsed.  So, you might need to wrap it in an If test, that way, if it fails, it won't be added as a WhereElement.  You could also optionally put in an Else and add a WhereElement with a default value if the parsing fails.  The other option would be to strip out the spaces with a Dim val As String = CType(_CurrentValue, String).Replace(" ", "") and then pass it over to the Double.Parse.

Any of those options will work fine for you without any side effects.

Robin J Giltner
Robin J Giltner
StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)
Group: Forum Members
Posts: 105, Visits: 650
Or possibly how about using the Val command to get whatever the numbers are at the front of the string if there are any.

loFieldValue.Add(Double.Parse(CType(Val(_CurrentValue), String)))

Thanks

Robin Giltner

Robin J Giltner
Robin J Giltner
StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)StrataFrame User (125 reputation)
Group: Forum Members
Posts: 105, Visits: 650
I have a few BrowseDialogs to populate a few Business Objects, works great, untill someone types some characters into a field corresponding to a Double/Float in the database and then the BuildWhereElement method fails converting that string to a double.  Ok, so we just add a Mask to the Float/Double field putting 10 '9's into the mask to give the user up to 10 spots to put in numbers only.  This works in removing characters from the textbox, but with using 9's, they can add spaces to the textbox, as in '3473 747 7' and such.  The same happens with 10 '0's as the mask. 

At this point I tried looking to the OnSearching Event to check the input, but wasn't getting this far, as at this point, there WhereClause is already/has tried to be built and it is too late to check the Input.  So now I am looking to adding a small amount of code to the BuildWhereElement method so that

Case DbType.Currency, DbType.Double

loFieldValue.Add(Double.Parse(CType(_CurrentValue, String)))

might not throw an exception.  I thought about possibly using Double.Tryparse but it works a little differently and would have to use a placeholder variable (no big deal) something maybe like

Dim lnValue As Double

Double.TryParse(CType(_CurrentValue, String), lnValue)

loFieldValue.Add(lnValue)

And this seems to fix the problem about putting spaces and putting characters into the textbox for our Double/Float fields, but I don't have the expertise to predict any future problems with this or other possible BrowseDialog side effects.

Any pointers on how we can make sure the user doesn't enter in any alpha characters and no spaces ?

*sigh* users...

Thanks

Robin Giltner

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search