﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » BrowseDialog SearchFieldItem and the BuildWhereElement method</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Thu, 24 Sep 2026 21:44:02 GMT</lastBuildDate><ttl>20</ttl><item><title>BrowseDialog SearchFieldItem and the BuildWhereElement method</title><link>http://forum.strataframe.net/FindPost11927.aspx</link><description>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.&amp;nbsp; 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.&amp;nbsp; 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.&amp;nbsp; The same happens with 10 '0's as the mask.&amp;nbsp; &lt;/P&gt;&lt;P&gt;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.&amp;nbsp; So now I am looking to adding a small amount of code to the BuildWhereElement method so that&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;P&gt;Case&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt; DbType.Currency, DbType.Double&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;loFieldValue.Add(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Double&lt;/FONT&gt;&lt;FONT size=2&gt;.Parse(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;CType&lt;/FONT&gt;&lt;FONT size=2&gt;(_CurrentValue, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt;)))&lt;/P&gt;&lt;/FONT&gt;&lt;P&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;might not throw an exception.&amp;nbsp; 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&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;FONT color=#0000ff size=2&gt;&lt;/P&gt;&lt;P&gt;Dim&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; lnValue &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Double&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Double&lt;/FONT&gt;&lt;FONT size=2&gt;.TryParse(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;CType&lt;/FONT&gt;&lt;FONT size=2&gt;(_CurrentValue, &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt;), lnValue)&lt;/P&gt;&lt;P&gt;loFieldValue.Add(lnValue)&lt;/P&gt;&lt;/FONT&gt;&lt;P&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Any pointers on how we can make sure the user doesn't enter in any alpha characters and no spaces ? &lt;/P&gt;&lt;P&gt;*sigh* &lt;EM&gt;users&lt;/EM&gt;...&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Robin Giltner</description><pubDate>Thu, 11 Oct 2007 09:04:44 GMT</pubDate><dc:creator>Robin J Giltner</dc:creator></item><item><title>RE: BrowseDialog SearchFieldItem and the BuildWhereElement method</title><link>http://forum.strataframe.net/FindPost11940.aspx</link><description>Awesome, thanks Ben.&lt;/P&gt;&lt;P&gt;Robin Giltner</description><pubDate>Thu, 11 Oct 2007 09:04:44 GMT</pubDate><dc:creator>Robin J Giltner</dc:creator></item><item><title>RE: BrowseDialog SearchFieldItem and the BuildWhereElement method</title><link>http://forum.strataframe.net/FindPost11939.aspx</link><description>The TryParse will work, but that method will return a True/False to indicate whether the value was properly parsed.&amp;nbsp; So, you might need to wrap it in an If test, that way, if it fails, it won't be added as a WhereElement.&amp;nbsp; You could also optionally put in an Else and add a WhereElement with a default value if the parsing fails.&amp;nbsp; 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.&lt;/P&gt;&lt;P&gt;Any of those options will work fine for you without any side effects.</description><pubDate>Thu, 11 Oct 2007 08:42:58 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: BrowseDialog SearchFieldItem and the BuildWhereElement method</title><link>http://forum.strataframe.net/FindPost11929.aspx</link><description>Or possibly how about using the Val command to get whatever the numbers are at the front of the string if there are any.&lt;/P&gt;&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;loFieldValue.Add(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Double&lt;/FONT&gt;&lt;FONT size=2&gt;.Parse(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;CType&lt;/FONT&gt;&lt;FONT size=2&gt;(Val(_CurrentValue), &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt;)))&lt;/P&gt;&lt;/FONT&gt;&lt;P&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Robin Giltner</description><pubDate>Tue, 09 Oct 2007 15:22:48 GMT</pubDate><dc:creator>Robin J Giltner</dc:creator></item></channel></rss>