1. Home
  2. Computing & Technology
  3. Visual Basic

ASP.NET - Learn Programming for the Networked World - Part 4

By Dan Mabbutt, About.com

5 of 8

Trying a Calculation

So let's try calculating something! Click one of the number buttons to get started and the problem I've been predicting pops up.

Public member 'tag' on type 'Button' not found.

At least there's quite a bit of information on the page to help you figure out the problem.

Since there just isn't any "tag" property to work with, we have to go into our code and do this a completely different way. The solution I decided to use was a "Select Case" structure in the "keyClick" event subroutine and a new "tag" variable so as much as possible of the previous code could be re-used. A similar structure has to be addded in the "op" subroutine for the operation keys.

~~~~~~~~~~~~~~~~~~~~~~~~~
Dim tag As String
Select Case sender.id
   Case "key0"
      tag = "0"
   Case "key1"
      tag = "1"
   Case "key2"

...

   Case "keydecimal"
      tag = "."
End Select
~~~~~~~~~~~~~~~~~~~~~~~~~

Since tag is now a local variable instead of a property that can be accessed through the "sender" argument. The easiest way to change this is to use Visual Studio's Find function and look for "tag" throughout the code. For example,

PendingOp = sender.tag

will be changed to

PendingOp = tag

Or, maybe not. There's still another problem, but let's run our calculator page again to see what it is.

5 of 8

Explore Visual Basic

More from About.com

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Learn VB.NET
  5. Learn ASP.NET
  6. ASP.NET - Learn Programming for the Networked World - Part 4

©2008 About.com, a part of The New York Times Company.

All rights reserved.