473,662 Members | 2,454 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

InvalidCastExce ption "Cast from string "6<5" to type 'Boolean is not valid.

I get an InvalidCastExce ption "Cast from string "6<5" to type 'Boolean is
not valid.

for

If (CInt(objBuyInf o.Budget) & " " & arrRuleList(i). operator & " "
& CInt(arrRuleLis t(i).LeadMember Value)) Then

where arrRuleList(i). operator = ">"

and CInt(objBuyInfo .Budget) = 6

and CInt(arrRuleLis t(i).LeadMember Value) = 5

The quickwatch shows "6 < 5" {String} Object
How can I create a legitimate expression from this property values?

Thank you,
-hazz


Nov 21 '05 #1
3 2002
You can't. You need to evaluate a string as if it were code, and there is
no easy way to do that. You would need to either parse it out yourself, or
there are ways you can write, compile and execute code at runtime (slow and
not so pretty).

In your case, I am not sure why you are turning things into Integers, just
to then turn them back into a string during concatentation?

The easiest way to do this in your particular case would be to write a
function that took as parameters the values to compare, and the operator.
Then just have a case statement on the operator, and perform the appropriate
comparison with the operands. Return the result of the comparison.

Also, you should turn Option Strict On. That would prevent these errors at
compile time, rather then at runtime. You should always keep this option
turned on.

"hazz" <gr*********@no spamcomcast.net > wrote in message
news:e5******** ********@tk2msf tngp13.phx.gbl. ..
I get an InvalidCastExce ption "Cast from string "6<5" to type 'Boolean is
not valid.

for

If (CInt(objBuyInf o.Budget) & " " & arrRuleList(i). operator & " "
& CInt(arrRuleLis t(i).LeadMember Value)) Then

where arrRuleList(i). operator = ">"

and CInt(objBuyInfo .Budget) = 6

and CInt(arrRuleLis t(i).LeadMember Value) = 5

The quickwatch shows "6 < 5" {String} Object
How can I create a legitimate expression from this property values?

Thank you,
-hazz

Nov 21 '05 #2
Thank you for your quick reply Marina!
Thank you for the following suggestion which I was beginning to see as the
only solution.
The easiest way to do this in your particular case would be to write a
function that took as parameters the values to compare, and the operator.
Then just have a case statement on the operator, and perform the
appropriate comparison with the operands. Return the result of the
comparison.


And thank you for your other comments. Option Strict On is a fixture now.

Appreciatively,
-hazz
Nov 21 '05 #3
hazz schrieb:
I get an InvalidCastExce ption "Cast from string "6<5" to type 'Boolean is
not valid.

for

If (CInt(objBuyInf o.Budget) & " " & arrRuleList(i). operator & " "
& CInt(arrRuleLis t(i).LeadMember Value)) Then

where arrRuleList(i). operator = ">"

and CInt(objBuyInfo .Budget) = 6

and CInt(arrRuleLis t(i).LeadMember Value) = 5

The quickwatch shows "6 < 5" {String} Object
How can I create a legitimate expression from this property values?

http://msdn.microsoft.com/library/en...elanguages.asp
Armin
Nov 21 '05 #4

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

Similar topics

5
2793
by: Eric A. Forgy | last post by:
Hello, I am just learning Java and am trying to write a method that does something like //=========================================== public Static List find(double array,double val,String relationalOp) { List list = new ArrayList();
7
9021
by: Ensoul Chee | last post by:
I used #include <iostream.h> int m; cout << "Hexadecimal == 0x" << hex << m << endl; to print value of m in hexadecimal mode. But I got the compile error like this couttest.cpp:20 `hex' undeclared (first use this function)
1
6820
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
3
2472
by: H. S. | last post by:
Hi, I am trying to compile these set of C++ files and trying out class inheritence and function pointers. Can anybody shed some light why my compiler is not compiling them and where I am going wrong? I am using g++ (GCC) 3.3.5 on a Debian Sarge system. The compiler complains: //**************************** //**************************** Compiler output starts *********** cd /home/red/tmp/testprogs/
1
1827
by: Kashish | last post by:
Is file<<"Some string"<<endl is an atomic operation. where file is an ofstream object. If we output a string in ofstream and we provide endl after that,Can we make sure the whole string will be put in file at a time or the string can appear in parts.String lenfth is no more than 50 chars. I have 2 processes on different solaris boxes (NFS) running in parallel.one process writing lines to the file and other process reading lines from...
4
1803
by: Andy Leszczynski | last post by:
watch this: http://www.turbogears.org.nyud.net:8090/docs/wiki20/20MinuteWiki.mov or read this: http://www.turbogears.org.nyud.net:8090/docs/wiki2 0/page4.html should not it be: 2 def save(self, pagename, data, submit, new): 3 hub.begin()
2
6839
by: andrew007 | last post by:
I do xml / xslt transformation using asp.net but I found any value (w/xml format) in xml node html-encoded to &lt and &gt format if it's > or < tag. Since I have sub xml data in a parent xml node as a value. Check out the following problem. I want to convert the value in <WpDatesXml> node to have a valid "<" and ">" instead of &lt or &gt format so that I can use this xml for another use. Please help! <NewDataSet> <Table1>
10
42955
by: Jon Noring | last post by:
Out of curiosity, may a CDATA section appear within an attribute value with datatype CDATA? And if so, how about other attribute value datatypes which accept the XML markup characters? To me, the XML specification seems a little ambiguous on this, so I defer to the XML authorities. Refer to sections 2.4 and 2.7 (it all hinges on if CDATA attribute values are part of markup or not.) Thanks.
1
12318
by: mato81 | last post by:
Hi all! I am a newbie to WSDL. I have a questions which has been driving me crazy... If I would have a WSDL with a types element somewhat like below, what is the point of the third last row "<s:element name="string" nillable="true" type="s:string"/>". Why is it there and what is it for? ... <wsdl:types> <s:schema elementFormDefault="qualified" targetNamespace="http://www.home.NET"> <s:element name="GetWeather">
0
8432
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8856
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8762
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8545
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7365
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.