Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search a string in VBScript to verify if contains a character

Tags:

vbscript

I am trying to see if a string contains a dot.

Set Root_Currency = Root_TaxDataSummary.SlvObject("Currency")   
curr_val = InStr(Root_Currency,".")
If curr_val.exist Then

     pass
else
     fail

Is there anything wrong with the way I am going about this?

like image 635
hankey39 Avatar asked Dec 13 '25 08:12

hankey39


1 Answers

InStr returns an integer representing the position the searched text can be found in the string.

curr_val.exist won't work because the integer type doesn't have an exist method. Instead:

If curr_val > 0 Then

Or (if this is the only use of that variable):

If InStr(Root_Currency,".") > 0 Then

Lastly, because 0 is treated as False in VBScript, you don't need to include the inequality operator. Either a position is found for the character or you get back a 0/false:

If InStr(Root_Currency,".") Then
like image 96
JNevill Avatar answered Dec 16 '25 23:12

JNevill