Jump to content
Xtreme .Net Talk

groberts1980

Members
  • Posts

    2
  • Joined

  • Last visited

About groberts1980

  • Birthday 03/11/1980

Personal Information

  • Visual Studio .NET Version
    Visual Studio .NET Standard 7
  • .NET Preferred Language
    VB.NET

groberts1980's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Two things. First, how do I pass the local variable into this function? And second, when I typed the function into the code, it gave me an error with (By Val value As Integer) it says "Comma, or ) expected." But I typed it exactly as you posted it. Sorry, I'm am a newbie at VB and I don't know exactly how to apply the idea here. groberts1980
  2. I'm writing a program for the VB class I'm taking, and I've run into a problem. Basically, I need the program to count how many times a button is clicked, and display the results when another button is pressed. Here is the code I have for the Driving Range button, the one to be counted: Static intDrivingRange As Integer intDrivingRange += 1 My professor requires that all our declerations be local, which is why I'm using static instead of a dim statement in the declerations section. These lines should add 1 to the integer DrivingRange each time the button is clicked. My problem is getting it to display the results when the Results button is clicked. Here's my code for the Results Button: Static intDrivingRange As Integer lblDrivingRange.Text = "Driving Range: " & (intDrivingRange) When I click the Driving Range button a few times, then click the Results button, it always says "Driving Range: 0" The part I can't figure is if I move the lblDrivingRange.text line into the same procedure as the counter, it keeps a running total as I'm clicking Driving Range button and works fine. But for the project I need it to simply keep count until I hit the Results button. Only then should it display the results. Is my problem with the counter or the way I'm trying to display the results? - groberts1980 P.S. Using class-level variables does work for this program. My problem is, at this stage, my professor wants us to use only local variables. There are 6 buttons I need counters for, and when I Dim all 6 variables at the class level, the program works fine. But like I said I have to use local variables. Is there any way to create the variable locally in the DrivingRange button procedure, and have the Results button use that variable and its value? If I have to turn in the program using class level variables I will, but I would prefer to have it work using only local variables. I know what you're thinking, there are probably many VB professors out there who are better than the one I got, but I'm stuck with him. Ergo, I'm stuck being told to use only local variables.
×
×
  • Create New...