Link to home
Start Free TrialLog in
Avatar of Roger Trippaers
Roger TrippaersFlag for Spain

asked on

Convert boolean value to String

Hello,

we want to control the IBAN bank number, with the code below we can get the (Boolean) value back as True or False, but we need to put the value in a normal value (string) to work with.

We work with ASP Classic.

Can you help us?
Thanks.
<%
dim IBANCHECK 
URLToRSS = "http://www.ibanbic.be/IBANBIC.asmx/CheckBBAN?Value="&Value&""
Set xmlHttp = Server.CreateObject("MSXML2.XMLHTTP.3.0")
xmlHttp.Open "Get", URLToRSS, false
xmlHttp.Send(null)

IBANCHECK=xmlHttp.ResponseText

Set xmlHttp = Nothing ' clear XML
%>

Open in new window

Avatar of Nitin Sontakke
Nitin Sontakke
Flag of India image


Hello,

I just checked and the returned XML response is:

<?xml version="1.0" encoding="UTF-8"?>
<boolean xmlns="http://tempuri.org/">false</boolean>

As you are using ResponseText property, you will probably get 'false' as a string in IBANCHECK variable anyway.

As a first attempt, have you already tried printing that value? Also try using following to be sure that it is indeed a boolean variable.

IF IBANCHECK THEN
  Response.Write("Yes it is TRUE")
ELSE
  Response.Write("No it is FALSE")
END IF

To convert it to boolean (or any intrinsic data-type for that matter) to string use CStr function as in
strIBANCHECK = CStr(IBANCHECK)

Hope it helps!
Avatar of Roger Trippaers

ASKER

We need to check if a Belgian IBAN account number is correct.

This is the url where we do the check:

http://www.ibanbic.be/IBANBIC.asmx?op=controleIBAN


When we enter a correct IBAN account number we get the value "true", so it not automatically get "false" back.

When we try your code we get the followin error:
-----------------------------------------------------------------------------
Runtimefout Microsoft VBScript error '800a000d'

Type does not match: '[string: "<?xml version="1.0" "]'

check_iban_db.asp, line 31
----------------------------------------------------------
Line 31: IF IBANCHECK THEN
ASKER CERTIFIED SOLUTION
Avatar of Roger Trippaers
Roger Trippaers
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
found the solution ourself and submitted it for other users
Or this:
''
IBANCHECK = Trim(Left(Right(xmlHttp.ResponseText, 15), 5))
''

Open in new window


No objection to closure as such.

One suggestion is to implement a solution which is not error-prone. The current will fail at the slightest change in response text.

The ideal way to do it would be to load the response in the XMLDocument, search the node and then extract the value. A dedicated function would be nice to have.

I concur; I merely refactored the multiple lines of code into a single line as posted by rogerspain.