469,603 Members | 2,117 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,603 developers. It's quick & easy.

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 1485
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by DJ Craig | last post: by
2 posts views Thread by Tim Mierzejewski | last post: by
2 posts views Thread by Kostatus | last post: by
1 post views Thread by programmingChick | last post: by
19 posts views Thread by Rajesh S R | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.