473,325 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

test for type of data in a string?

Is there a way to test wether a string contains only numbers?

I have a form with some (29) comboboxes.
One combobox is bound to a table with only numeric values whereas
another is bound to a textfield
Hello there!
I have code that basically loops through the comboboxes and IF the
combobox contains a value that value will be used in a filter that is
used as a criterium in a query;

varFilter = varFilter & "((" & varVeldOnderCombo & ") = " &
varComboWaarde & ")"

If VarcomboWaarde is numeric I need the code as above, else I need the
last part with extra quotes.

In short, what I am looking for is code that follows the logic shown
below. Any sugggestions?

IF varComboWaarde is a number THEN
varFilter = varFilter & "((" & varVeldOnderCombo & ") = " &
varComboWaarde & ")"
ELSE
varFilter = varFilter & "((" & varVeldOnderCombo & ") = '" &
varComboWaarde & "')"
END IF
TIA Henro

Mar 7 '07 #1
5 4553

IsNumeric(exp a variant) funtion will return true if the exp is
equivlaent to a number (ie no letters or punctuation other than those
allowed in a number)

If IsNumeric(expression) Then
....
Else
....
End If

Mar 7 '07 #2
On 7 mrt, 17:32, "storrboy" <storr...@sympatico.cawrote:
IsNumeric(exp a variant) funtion will return true if the exp is
equivlaent to a number (ie no letters or punctuation other than those
allowed in a number)

If IsNumeric(expression) Then
....
Else
....
End If
Thank you storrboy!

Mar 8 '07 #3
IsNumeric() is useful, but some results may surprise you.

Press Ctrl+G to open the Immediate window, and try:
? IsNumeric(245E+2#)
The answer is True, because VBA recogises it as a number in scientific
format.

Likewise
? IsNumeric(-5.9999@)
is a number (with a trailing type declaration character.)

This is true:
? IsNumeric("0.07")
But this is false:
? IsNumeric("7%")

And this is true:
? IsNumeric(Henrootje)
(It's an undeclared variant, initialized to Empty, which is equivalent to a
zero in numeric contexts.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Henrootje" <He****@gmail.comwrote in message
news:11**********************@n33g2000cwc.googlegr oups.com...
On 7 mrt, 17:32, "storrboy" <storr...@sympatico.cawrote:
>IsNumeric(exp a variant) funtion will return true if the exp is
equivlaent to a number (ie no letters or punctuation other than those
allowed in a number)

If IsNumeric(expression) Then
....
Else
....
End If

Thank you storrboy!
Mar 8 '07 #4

On 8 mrt, 08:43, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
<snip>
And this is true:
? IsNumeric(Henrootje)
(It's an undeclared variant, initialized to Empty, which is equivalent to a
zero in numeric contexts.)
<>snip>

Allen,

Are you suggesting that I am an undeclared variant, initialized to
Empty, which is equivalent to a zero in numeric contexts?
:p

but seriously,
thanks for pointing these out to me. I have checked whether such a
situation could arise over here but luckily it can't.
(except for me being an undeclared variant, initialized to Empty,
which is equivalent to a zero in numeric contexts, THAT is entirely
possible)

Greetings Henro
"Henrootje" <Hen...@gmail.comwrote in message

news:11**********************@n33g2000cwc.googlegr oups.com...
On 7 mrt, 17:32, "storrboy" <storr...@sympatico.cawrote:
IsNumeric(exp a variant) funtion will return true if the exp is
equivlaent to a number (ie no letters or punctuation other than those
allowed in a number)
If IsNumeric(expression) Then
....
Else
....
End If
Thank you storrboy!- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -

Mar 9 '07 #5
:-)

Oops. Got to be more careful what we say here. ;-]

Many years ago, I posted a bit of VBA fun for those who prefer
object-oriented databases, and later found it had made its way onto a geek
website:

Dim Everything As Object
If Everything Is Nothing Then
MsgBox "This is a paradox of the object-oriented universe."
End If

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Henrootje" <He****@gmail.comwrote in message
news:11*********************@p10g2000cwp.googlegro ups.com...
>
On 8 mrt, 08:43, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
<snip>
>And this is true:
? IsNumeric(Henrootje)
(It's an undeclared variant, initialized to Empty, which is equivalent to
a
zero in numeric contexts.)

<>snip>

Allen,

Are you suggesting that I am an undeclared variant, initialized to
Empty, which is equivalent to a zero in numeric contexts?
:p

but seriously,
thanks for pointing these out to me. I have checked whether such a
situation could arise over here but luckily it can't.
(except for me being an undeclared variant, initialized to Empty,
which is equivalent to a zero in numeric contexts, THAT is entirely
possible)

Greetings Henro
>"Henrootje" <Hen...@gmail.comwrote in message

news:11**********************@n33g2000cwc.googleg roups.com...
On 7 mrt, 17:32, "storrboy" <storr...@sympatico.cawrote:
IsNumeric(exp a variant) funtion will return true if the exp is
equivlaent to a number (ie no letters or punctuation other than those
allowed in a number)
>If IsNumeric(expression) Then
....
Else
....
End If
Thank you storrboy!- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -
Mar 9 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: shivaprasad | last post by:
Hi all, I am a Beginner to c#. I Need to convert array of byte data type to string. How to do this.. ex: byte bytes = new byte; this bytes get filled up. Now I need to convert to string.
3
by: Imran Aziz | last post by:
Hello All, I am getting the following error on our production server, and I dont get the same error on the development box. Unable to cast object of type 'System.Byte' to type 'System.String'. ...
1
by: Marc | last post by:
Hi! I'm working with a C# client that calls a php web service. I've created a wrapper to call the service using .NET wsdl tool (adding a web reference). The call to the server works fine, it...
2
by: John Smith | last post by:
I'm writing webervice client using .Net 2.0. I have this class: public class MyWebService : SoapHttpClientProtocol { public XmlDocument validate(string url, XmlDocument xmlDocument) {...
3
by: keithb | last post by:
What could be causing this? this code: String Com = ""; if (Com != (String)rw.ItemArray) fails at runtime with the error message: Unable to cast object of type 'System.Int32' to type...
7
by: Sky | last post by:
I have been looking for a more powerful version of GetType(string) that will find the Type no matter what, and will work even if only supplied "{TypeName}", not the full "{TypeName},{AssemblyName}"...
3
by: Ruben | last post by:
Hi! I am looking for an easy way to get a Type from a arbitrary string. What I found looks like: ---- string TypeString = "System.String"; // only as example... Type TypeIAmLookingFor =...
8
by: Martin Eckart | last post by:
Hi folks, Who can explain me why the following expression does not result in getting the correct type, but null: Type t = Type.GetType("System.Xml.XmlReader"); For "System.String" it works...
1
by: Slippy27 | last post by:
How do I test a byte string in Python? I want to manually convert (no libraries or functions) a UTF-8 string into UTF-16. My basic solution is to read from the stream some number of UTF-8 bytes,...
3
by: Nathan Sokalski | last post by:
I have the following code: Dim values As New ArrayList() values.Add("Yes") values.Add("No") values.Add("Maybe") values.Add("Whatever") dim x as String()=values.ToArray() However, I recieve...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.