Results 1 to 3 of 3

Thread: visual basic

  1. #1

    visual basic

    I have to do a project in VB for school, and as much as I hate it I have to pretend I know it, could anyone help me with:

    Resetting a variable, I want to be able to click a button and the variable is reset back to zero, i tried var = 0 but it doesn`t affect it, and i need it to remember its' value so i did:
    static var as currency, so what i`m asking is, is there a way to reset a variable which has been declared static?

    Also, how do you test whether user-input is a certain type or not, i.e if it's a string, or a integer etc, i can`t find a function for it anywhere.

    Anyway if you've read this far, thank you.

    And I appologise, it appears this isn't the general forum... there's just so many!

    Sorry `bout this.

  2. #2
    Senior Member
    Join Date
    Oct 2001
    If you have the code written it might be useful to post it here.

    You could store the static variable into another variable for changing.

    Also, you can use IsNumeric to check if the input is a number. Returns true if it is.
    Or you could use ToString and convert the input to a string.

  3. #3
    Senior Member
    Join Date
    Dec 2001
    Kind of sounds like you're declaring the variable in a sub, setting it to 0, then it gets discarded when the method call is done. If you declare it static then you will not be able to change it directly. Another thing to check for, if you did declare that variable globally (at the top of your source, outside any sub's) then look to see if you declare a variable with the same name inside the sub you're setting it with, because it will set the one inside to the value while never touching the other unless you have some way of referencing it (not sure how in VB, I try to avoid this scenario most times and I'm more of a c++ guy). And yes, please show us the source, most people who know the language can point out simple flaws right away when they see them.

    Oh and this isn't site related... post in the right forum next time
    Reality is the one who has it wrong, not you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts