Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 249
  • Last Modified:

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

Hi,
I have a string with
-64.71
Need to check whether string is negative.

Cheers
0
RIAS
Asked:
RIAS
  • 2
2 Solutions
 
cy_hungCommented:
let's try this :

if val(string4test) < 0 then
 debug.print "TRUE"
else
 debug.print "FALSE"
end
0
 
Éric MoreauSenior .Net ConsultantCommented:
if yourStringVariable.IndexOf("-")>=0 then
  'it contains a -
end if
0
 
Éric MoreauSenior .Net ConsultantCommented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now