Re: Operand

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Arpan (arpan_de_at_hotmail.com)
Date: 11/19/04


Date: Fri, 19 Nov 2004 17:40:53 +0530

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" <kspencer@takempis.com> wrote in message news:O4ZDkk%23yEHA.1412@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" <arpan_de@hotmail.com> wrote in message
  news:esFxr#2yEHA.2568@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



Relevant Pages

  • RE: Sections in repeater
    ... Public Class Responsibility ... Public Property PersonAs String ... Public Sub New(ByVal activityStart As DateTime, ByVal person As String, ... Dim litSection As Literal ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Project Error
    ... Private Declare Sub Sleep Lib "Kernel32" ... Dim strDataSrc As String ...
    (microsoft.public.vb.bugs)
  • Re: FTP CD command
    ... My code connects to a ftp site and the enumerates all content on that place ... Public Property UriAs String ... End Sub ... Dim listRequest As FtpWebRequest = CType, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: FTP CD command
    ... Private _Uri As String ... End Sub ... Dim listRequest As FtpWebRequest = CType, ... Public Sub UploadAsynch(ByVal fileName As String, ByVal uploadUrl As ...
    (microsoft.public.dotnet.languages.vb)
  • Re: FTP CD command
    ... i remember to have seen a socket level FTP ... Private _Uri As String ... End Sub ... Dim listRequest As FtpWebRequest = CType, ...
    (microsoft.public.dotnet.languages.vb)