Operand

A

Arpan

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
 
Y

Yama

Try to box them to integer...

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



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
 
K

Kevin Spencer

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.


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
 
A

Arpan

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
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.


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
 
A

Arpan

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
Try to box them to integer...

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



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
 
K

Kevin Spencer

Sure, Arpan,

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/vbconDataTypes.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/...A6-3647-4070-9F41-A333C6B9181D&displaylang=en

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

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
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.


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top