?
Solved

How to find string is a negative value string +vb.net

Posted on 2010-01-11
3
Medium Priority
?
246 Views
Last Modified: 2012-06-27
Hi,
I have a string with
-64.71
Need to check whether string is negative.

Cheers
0
Comment
Question by:RIAS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
cy_hung earned 500 total points
ID: 26284143
let's try this :

if val(string4test) < 0 then
 debug.print "TRUE"
else
 debug.print "FALSE"
end
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 26284148
if yourStringVariable.IndexOf("-")>=0 then
  'it contains a -
end if
0
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 500 total points
ID: 26284163
safer method:

        Dim decValue As Decimal
        Dim strValue As String = "-64.71"
        Decimal.TryParse(strValue, decValue)
        If decValue < 0 Then
            'negative
        End If
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question