473,403 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Operand

I am trying to make a calculator in ASP.NET using VB.NET but certain errors are cropping up. This is a part of the code (please note that the code lines that are bold & in red colour generate the errors):

<%@ Page Language="VB" Debug="true" Explicit="true" %>
<%@ Import Namespace="System.Drawing.Color" %>
<%@ Import Namespace="System.Math" %>

Sub btnInv(obj As Object,ea As EventArgs)
If(invnum1.Value="") Then
If(num1.Value<>"") Then
answer.Text=Left(1/num1.Value,13)
invnum1.Value=num1.Value
Else
If(storemem.Value<>"") Then
answer.Text=Left(1/storemem.Value,13)
End If
End If
End Sub

This is the error that is being generated:

The operands to '/' are of types 'System.Integer' & 'System.String', which are not appropriate for this operator.

If I comment out the above lines, another error gets generated as shown below:

Sub btnMR(obj As Object,ea As EventArgs)
If((op="") And (storemem.Value<>0)) Then
..................
..................
End If

If((op<>"") And (storemem.Value<>0)) Then
.................
.................
End If
End Sub

This is the second error that is being generated:

The operands to '<>' are of types 'System.String' & 'System.Integer' which are not appropriate for this operator.

If I comment out the above lines as well, a third error gets generated as shown below:

Sub btnMC(obj As Object,ea As EventArgs)
If((op<>"") And (storemem.Value=0)) Then
...............
...............
End If

If((op="") And (storemem.Value=0)) Then
..............
..............
End If
End Sub

& this is the error message:

The operands to '=' are of types 'System.String' & 'System.Integer', which are not appropriate for this operator.

I am not understanding why are the errors being generated. Could somebody please help me out to overcome the above-mentioned errors?

I am working on Windows 2K Professional & have .NET Framework v.1.0.2204 installed in my m/c.

Thanks,

Arpan
Nov 18 '05 #1
5 1692
Try to box them to integer...

answer.Text=(double)( 1/ (double)num1.Value ).ToString().PadLeft(13);

"Arpan" <ar******@hotmail.com> wrote in message news:es****************@TK2MSFTNGP10.phx.gbl...
I am trying to make a calculator in ASP.NET using VB.NET but certain errors are cropping up. This is a part of the code (please note that the code lines that are bold & in red colour generate the errors):

<%@ Page Language="VB" Debug="true" Explicit="true" %>
<%@ Import Namespace="System.Drawing.Color" %>
<%@ Import Namespace="System.Math" %>

Sub btnInv(obj As Object,ea As EventArgs)
If(invnum1.Value="") Then
If(num1.Value<>"") Then
answer.Text=Left(1/num1.Value,13)
invnum1.Value=num1.Value
Else
If(storemem.Value<>"") Then
answer.Text=Left(1/storemem.Value,13)
End If
End If
End Sub

This is the error that is being generated:

The operands to '/' are of types 'System.Integer' & 'System.String', which are not appropriate for this operator.

If I comment out the above lines, another error gets generated as shown below:

Sub btnMR(obj As Object,ea As EventArgs)
If((op="") And (storemem.Value<>0)) Then
..................
..................
End If

If((op<>"") And (storemem.Value<>0)) Then
.................
.................
End If
End Sub

This is the second error that is being generated:

The operands to '<>' are of types 'System.String' & 'System.Integer' which are not appropriate for this operator.

If I comment out the above lines as well, a third error gets generated as shown below:

Sub btnMC(obj As Object,ea As EventArgs)
If((op<>"") And (storemem.Value=0)) Then
...............
...............
End If

If((op="") And (storemem.Value=0)) Then
..............
..............
End If
End Sub

& this is the error message:

The operands to '=' are of types 'System.String' & 'System.Integer', which are not appropriate for this operator.

I am not understanding why are the errors being generated. Could somebody please help me out to overcome the above-mentioned errors?

I am working on Windows 2K Professional & have .NET Framework v.1.0.2204 installed in my m/c.

Thanks,

Arpan
Nov 18 '05 #2
Do yourself a favor, and turn Option Strict ON. You need to learn about data
types. In VB, everything was a variant. Well, not really, but it sure made
it look that way. Just Microsoft's way of not worrying your pretty little
head about all that technical stuff that really goes on in a program. If you
assigned a numeric string to a string, you could treat it just like a
number, and as long as VB was able to convert whatever was in that string to
a number at run-time, it was perfectly happy, and so were you. You didn't
even have to be aware that VB was doing all this conversion for you. As a
result, an entire generation of "programmers" grew up thinking that there
was no such thing as a data type.

VB.Net is like VB for grown-ups. You have to take more responsibility for
what your application does. At the very least, you need to understand data
types. VB.Net is much more powerful, but that power comes at the price of
responsibility.

A string is an array of characters ending with a null 0 character. A
character is an 8-bit (1 byte) integer. An Integer is a 32-bit (4 byte)
integer. The platform needs to know the data type because it must allocate
the amount of memory necessary to store and work with the data.

A text box holds text (string) data. Just because you're validating only
numeric characters in it doesn't mean that it contains numbers. '25' and 25
are 2 completely different types of data. One is a string composed of 2
characters, '2' and '5,' and '\0'. The other is a 32-bit Integer containing
the value 25 in it (00000000000000000000000000011001). It would be perfectly
valid to assign 'Me' to the string value. It would not be alright to add a
32-bit Integer and a 2-character string. Neither could you assign the value
'32' to the Integer variable containing the value 25.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
"Arpan" <ar******@hotmail.com> wrote in message
news:es**************@TK2MSFTNGP10.phx.gbl...
I am trying to make a calculator in ASP.NET using VB.NET but certain errors
are cropping up. This is a part of the code (please note that the code lines
that are bold & in red colour generate the errors):

<%@ Page Language="VB" Debug="true" Explicit="true" %>
<%@ Import Namespace="System.Drawing.Color" %>
<%@ Import Namespace="System.Math" %>

Sub btnInv(obj As Object,ea As EventArgs)
If(invnum1.Value="") Then
If(num1.Value<>"") Then
answer.Text=Left(1/num1.Value,13)
invnum1.Value=num1.Value
Else
If(storemem.Value<>"") Then
answer.Text=Left(1/storemem.Value,13)
End If
End If
End Sub

This is the error that is being generated:

The operands to '/' are of types 'System.Integer' & 'System.String', which
are not appropriate for this operator.

If I comment out the above lines, another error gets generated as shown
below:

Sub btnMR(obj As Object,ea As EventArgs)
If((op="") And (storemem.Value<>0)) Then
..................
..................
End If

If((op<>"") And (storemem.Value<>0)) Then
.................
.................
End If
End Sub

This is the second error that is being generated:

The operands to '<>' are of types 'System.String' & 'System.Integer' which
are not appropriate for this operator.

If I comment out the above lines as well, a third error gets generated as
shown below:

Sub btnMC(obj As Object,ea As EventArgs)
If((op<>"") And (storemem.Value=0)) Then
...............
...............
End If

If((op="") And (storemem.Value=0)) Then
..............
..............
End If
End Sub

& this is the error message:

The operands to '=' are of types 'System.String' & 'System.Integer', which
are not appropriate for this operator.

I am not understanding why are the errors being generated. Could somebody
please help me out to overcome the above-mentioned errors?

I am working on Windows 2K Professional & have .NET Framework v.1.0.2204
installed in my m/c.

Thanks,

Arpan
Nov 18 '05 #3
Thanks, Kevin, for your response. It was indeed very nice of you to give me an explanation on datatypes. Could you please suggest some websites providing more info on datatype conversions in ASP.NET?

Thanks once again,

Regards,

Arpan
"Kevin Spencer" <ks******@takempis.com> wrote in message news:O4****************@tk2msftngp13.phx.gbl...
Do yourself a favor, and turn Option Strict ON. You need to learn about data
types. In VB, everything was a variant. Well, not really, but it sure made
it look that way. Just Microsoft's way of not worrying your pretty little
head about all that technical stuff that really goes on in a program. If you
assigned a numeric string to a string, you could treat it just like a
number, and as long as VB was able to convert whatever was in that string to
a number at run-time, it was perfectly happy, and so were you. You didn't
even have to be aware that VB was doing all this conversion for you. As a
result, an entire generation of "programmers" grew up thinking that there
was no such thing as a data type.

VB.Net is like VB for grown-ups. You have to take more responsibility for
what your application does. At the very least, you need to understand data
types. VB.Net is much more powerful, but that power comes at the price of
responsibility.

A string is an array of characters ending with a null 0 character. A
character is an 8-bit (1 byte) integer. An Integer is a 32-bit (4 byte)
integer. The platform needs to know the data type because it must allocate
the amount of memory necessary to store and work with the data.

A text box holds text (string) data. Just because you're validating only
numeric characters in it doesn't mean that it contains numbers. '25' and 25
are 2 completely different types of data. One is a string composed of 2
characters, '2' and '5,' and '\0'. The other is a 32-bit Integer containing
the value 25 in it (00000000000000000000000000011001). It would be perfectly
valid to assign 'Me' to the string value. It would not be alright to add a
32-bit Integer and a 2-character string. Neither could you assign the value
'32' to the Integer variable containing the value 25.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
"Arpan" <ar******@hotmail.com> wrote in message
news:es**************@TK2MSFTNGP10.phx.gbl...
I am trying to make a calculator in ASP.NET using VB.NET but certain errors
are cropping up. This is a part of the code (please note that the code lines
that are bold & in red colour generate the errors):

<%@ Page Language="VB" Debug="true" Explicit="true" %>
<%@ Import Namespace="System.Drawing.Color" %>
<%@ Import Namespace="System.Math" %>

Sub btnInv(obj As Object,ea As EventArgs)
If(invnum1.Value="") Then
If(num1.Value<>"") Then
answer.Text=Left(1/num1.Value,13)
invnum1.Value=num1.Value
Else
If(storemem.Value<>"") Then
answer.Text=Left(1/storemem.Value,13)
End If
End If
End Sub

This is the error that is being generated:

The operands to '/' are of types 'System.Integer' & 'System.String', which
are not appropriate for this operator.

If I comment out the above lines, another error gets generated as shown
below:

Sub btnMR(obj As Object,ea As EventArgs)
If((op="") And (storemem.Value<>0)) Then
..................
..................
End If

If((op<>"") And (storemem.Value<>0)) Then
.................
.................
End If
End Sub

This is the second error that is being generated:

The operands to '<>' are of types 'System.String' & 'System.Integer' which
are not appropriate for this operator.

If I comment out the above lines as well, a third error gets generated as
shown below:

Sub btnMC(obj As Object,ea As EventArgs)
If((op<>"") And (storemem.Value=0)) Then
...............
...............
End If

If((op="") And (storemem.Value=0)) Then
..............
..............
End If
End Sub

& this is the error message:

The operands to '=' are of types 'System.String' & 'System.Integer', which
are not appropriate for this operator.

I am not understanding why are the errors being generated. Could somebody
please help me out to overcome the above-mentioned errors?

I am working on Windows 2K Professional & have .NET Framework v.1.0.2204
installed in my m/c.

Thanks,

Arpan
Nov 18 '05 #4
Thanks, Yama, for your reply. I tried out your suggestion but it throws the following error:

'System.Double' is a module, and so is not a valid expression. Expected a variable, constant, or procedure.

What does the above error mean? How do I overcome it?

Thanks once again,

Regards,

Arpan
"Yama" <yk*****@stbernard.com> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
Try to box them to integer...

answer.Text=(double)( 1/ (double)num1.Value ).ToString().PadLeft(13);

"Arpan" <ar******@hotmail.com> wrote in message news:es****************@TK2MSFTNGP10.phx.gbl...
I am trying to make a calculator in ASP.NET using VB.NET but certain errors are cropping up. This is a part of the code (please note that the code lines that are bold & in red colour generate the errors):

<%@ Page Language="VB" Debug="true" Explicit="true" %>
<%@ Import Namespace="System.Drawing.Color" %>
<%@ Import Namespace="System.Math" %>

Sub btnInv(obj As Object,ea As EventArgs)
If(invnum1.Value="") Then
If(num1.Value<>"") Then
answer.Text=Left(1/num1.Value,13)
invnum1.Value=num1.Value
Else
If(storemem.Value<>"") Then
answer.Text=Left(1/storemem.Value,13)
End If
End If
End Sub

This is the error that is being generated:

The operands to '/' are of types 'System.Integer' & 'System.String', which are not appropriate for this operator.

If I comment out the above lines, another error gets generated as shown below:

Sub btnMR(obj As Object,ea As EventArgs)
If((op="") And (storemem.Value<>0)) Then
..................
..................
End If

If((op<>"") And (storemem.Value<>0)) Then
.................
.................
End If
End Sub

This is the second error that is being generated:

The operands to '<>' are of types 'System.String' & 'System.Integer' which are not appropriate for this operator.

If I comment out the above lines as well, a third error gets generated as shown below:

Sub btnMC(obj As Object,ea As EventArgs)
If((op<>"") And (storemem.Value=0)) Then
...............
...............
End If

If((op="") And (storemem.Value=0)) Then
..............
..............
End If
End Sub

& this is the error message:

The operands to '=' are of types 'System.String' & 'System.Integer', which are not appropriate for this operator.

I am not understanding why are the errors being generated. Could somebody please help me out to overcome the above-mentioned errors?

I am working on Windows 2K Professional & have .NET Framework v.1.0.2204 installed in my m/c.

Thanks,

Arpan
Nov 18 '05 #5
Sure, Arpan,

http://msdn.microsoft.com/library/de...nDataTypes.asp

This is part of the online .Net SDK. You can also download the entire .Net
SDK for free and use it on your computer:

http://www.microsoft.com/downloads/d...displaylang=en

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Arpan" <ar******@hotmail.com> wrote in message
news:uN**************@TK2MSFTNGP15.phx.gbl...
Thanks, Kevin, for your response. It was indeed very nice of you to give me
an explanation on datatypes. Could you please suggest some websites
providing more info on datatype conversions in ASP.NET?

Thanks once again,

Regards,

Arpan
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:O4****************@tk2msftngp13.phx.gbl...
Do yourself a favor, and turn Option Strict ON. You need to learn about
data
types. In VB, everything was a variant. Well, not really, but it sure made
it look that way. Just Microsoft's way of not worrying your pretty little
head about all that technical stuff that really goes on in a program. If
you
assigned a numeric string to a string, you could treat it just like a
number, and as long as VB was able to convert whatever was in that string
to
a number at run-time, it was perfectly happy, and so were you. You didn't
even have to be aware that VB was doing all this conversion for you. As a
result, an entire generation of "programmers" grew up thinking that there
was no such thing as a data type.

VB.Net is like VB for grown-ups. You have to take more responsibility for
what your application does. At the very least, you need to understand data
types. VB.Net is much more powerful, but that power comes at the price of
responsibility.

A string is an array of characters ending with a null 0 character. A
character is an 8-bit (1 byte) integer. An Integer is a 32-bit (4 byte)
integer. The platform needs to know the data type because it must allocate
the amount of memory necessary to store and work with the data.

A text box holds text (string) data. Just because you're validating only
numeric characters in it doesn't mean that it contains numbers. '25' and
25
are 2 completely different types of data. One is a string composed of 2
characters, '2' and '5,' and '\0'. The other is a 32-bit Integer
containing
the value 25 in it (00000000000000000000000000011001). It would be
perfectly
valid to assign 'Me' to the string value. It would not be alright to add a
32-bit Integer and a 2-character string. Neither could you assign the
value
'32' to the Integer variable containing the value 25.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
"Arpan" <ar******@hotmail.com> wrote in message
news:es**************@TK2MSFTNGP10.phx.gbl...
I am trying to make a calculator in ASP.NET using VB.NET but certain
errors
are cropping up. This is a part of the code (please note that the code
lines
that are bold & in red colour generate the errors):

<%@ Page Language="VB" Debug="true" Explicit="true" %>
<%@ Import Namespace="System.Drawing.Color" %>
<%@ Import Namespace="System.Math" %>

Sub btnInv(obj As Object,ea As EventArgs)
If(invnum1.Value="") Then
If(num1.Value<>"") Then
answer.Text=Left(1/num1.Value,13)
invnum1.Value=num1.Value
Else
If(storemem.Value<>"") Then
answer.Text=Left(1/storemem.Value,13)
End If
End If
End Sub

This is the error that is being generated:

The operands to '/' are of types 'System.Integer' & 'System.String', which
are not appropriate for this operator.

If I comment out the above lines, another error gets generated as shown
below:

Sub btnMR(obj As Object,ea As EventArgs)
If((op="") And (storemem.Value<>0)) Then
..................
..................
End If

If((op<>"") And (storemem.Value<>0)) Then
.................
.................
End If
End Sub

This is the second error that is being generated:

The operands to '<>' are of types 'System.String' & 'System.Integer' which
are not appropriate for this operator.

If I comment out the above lines as well, a third error gets generated as
shown below:

Sub btnMC(obj As Object,ea As EventArgs)
If((op<>"") And (storemem.Value=0)) Then
...............
...............
End If

If((op="") And (storemem.Value=0)) Then
..............
..............
End If
End Sub

& this is the error message:

The operands to '=' are of types 'System.String' & 'System.Integer', which
are not appropriate for this operator.

I am not understanding why are the errors being generated. Could somebody
please help me out to overcome the above-mentioned errors?

I am working on Windows 2K Professional & have .NET Framework v.1.0.2204
installed in my m/c.

Thanks,

Arpan

Nov 18 '05 #6

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

Similar topics

6
by: DJ Craig | last post by:
I keep getting this error: Fatal error: Unsupported operand types in /usr/local/etc/httpd/htdocs/djtricities/kat/bpmchart/chart.php on line 58 I've looked for hours for some type of error, and...
2
by: Tim Mierzejewski | last post by:
You guys were so great with answering my first question that I've decided to ask you yet again! Again, only the relevant code is included. typedef unsigned int unint; #include <iostream> ...
2
by: Kostatus | last post by:
The following code worked perfectly fine until i modified an unrelated part of the program: this->dungArea.mBlocked = mioS.mio_dungArea.mFlags & isBlocked; after that i started getting the...
15
by: Patrick.O.Ige | last post by:
Hi All i'm getting error with my TreeView Menu(I want to have a button with ExpandALL and CollapseALL):- Error:- 'AddressOf' operand must be the name of a method; no parentheses are needed. I...
6
by: BlueTrin | last post by:
Hello I was adapting a C version of SolvOpt in C++ to use it within a virtual class. However I am stuck with the overriding of evaluation and gradiant functions. cStepCurveEvaluator.cpp...
1
by: programmingChick | last post by:
I have a program where I want to accept an operand (from a file) and apply that operand to some integers. How should I do that? Is the best way to convert it to its ascii character then figure out...
19
by: Rajesh S R | last post by:
Consider the following code: int main() { struct name { long a; int b; long c; }s={3,4,5},*p; p=&s;
1
by: siresoth666 | last post by:
Greeting to everyone, I am a rookie at ASP and this may seem like a very simpleton question to most but I am clueless about it. I copied a code from a tutorial on to Flash its ASP but it does not...
7
by: somenath | last post by:
Hi All, I am trying to undestand "Type Conversions" from K&R book.I am not able to understand the bellow mentioned text "Conversion rules are more complicated when unsigned operands are...
8
by: Gilbert Fine | last post by:
This is a very strange exception raised from somewhere in our program. I have no idea how this happen. And don't know how to reproduce. It just occurs from time to time. Can anyone give me some...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.