Results 1 to 10 of 10
  1. #1
    yair's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Posts
    50
    Reputation
    10
    Thanks
    1

    [Help] Differences between Constants and Variables [Solved]

    so i have been taking a course of VB recently...and ive been doing fine but now its gotten a bit more difficult...heres a link to the project i have to make...
    any help will be greatly appreciated

    https://rion.ws/Mesa/Project2Assign.pdf

    im a bit comfused about the dim and constant....i dont know which one im suppose to use

  2. #2
    Lyoto Machida's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Far away with girls
    Posts
    3,734
    Reputation
    133
    Thanks
    1,621
    My Mood
    Aggressive
    I dont understand your question...
    Dim its to declare things like string, integer blabla...

  3. #3
    yair's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Posts
    50
    Reputation
    10
    Thanks
    1
    what would i declare for this project???

    Accessories (Stereo system = $425.76, Leather interior = $987.41, Computer navigation = $1,741.23), Detailing (Standard = 0, Pearlized = $345.72, Customized = $599.99), Tax rate = 8%

    so out of all of this which would be my const and dim???
    Last edited by NextGen1; 03-05-2011 at 02:07 PM. Reason: didn't edit, using this as a test

  4. #4
    ♪~ ᕕ(ᐛ)ᕗ's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Location
    Uterus
    Posts
    9,119
    Reputation
    1096
    Thanks
    1,970
    My Mood
    Doh
    it's like a calculator dude.....

  5. #5
    Lyoto Machida's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Far away with girls
    Posts
    3,734
    Reputation
    133
    Thanks
    1,621
    My Mood
    Aggressive
    On the button Calculate you must do something like this:

    Code:
    TextboxTotal.Text = CInt(TextboxPrice.Text) + CInt(TextboxPrice2.Text) ' ETC...
    And on the CheckBox Checked Change do this:

    Code:
    If YourCheckBox.Checked = True Then 
    
    TextboxPrice.Text = "Your Price"
    
    End if
    
    if YourCheckbox2.Checked = True Then
    
    TextboxPrice2.Text = "Your 2 Price"
    
    End if
    Its almost the same to the radio buttons...

    Its something like that xD
    Now just think about it!
    Last edited by Lyoto Machida; 03-05-2011 at 03:06 PM.

  6. The Following User Says Thank You to Lyoto Machida For This Useful Post:

    yair (03-06-2011)

  7. #6
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Consts are "Constants" the value that they hold cannot be changed at runtime. Dim declares a variable which, like it sounds, holds a variable value. You can make it hold any value of the same type (String. Integer, Decimal). So if those prices are fixed within your program, declare them as constants.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  8. The Following User Says Thank You to Jason For This Useful Post:

    yair (03-06-2011)

  9. #7
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    In Visual Basic, Dim officially tells the compiler that we are going to declare a variable. A variable can change its value anywhere in the program.

    Constants, on other hand are variable modifiers that represent a constant value, a value that can be computed at compile-time. Constants are fixed values and cannot change their value once initialized.

    Having said that, use constants if you are not going to change the values. Else, simply use variables.

  10. The Following User Says Thank You to Hassan For This Useful Post:

    Lyoto Machida (03-06-2011)

  11. #8
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,033
    Reputation
    340
    Thanks
    2,792
    My Mood
    Sad
    Quote Originally Posted by Hassan View Post
    In Visual Basic, Dim officially tells the compiler that we are going to declare a variable. A variable can change its value anywhere in the program.

    Constants, on other hand are variable modifiers that represent a constant value, a value that can be computed at compile-time. Constants are fixed values and cannot change their value once initialized.

    Having said that, use constants if you are not going to change the values. Else, simply use variables.
    For reference: Constants are pretty much semantics. In memory, they're all the same as normal integer values.

  12. #9
    yair's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Posts
    50
    Reputation
    10
    Thanks
    1
    thank you everyone...i understand better...

  13. #10
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Alrighty glad we could be of service. Thread marked solved, I doubt there is any need for anyone to post further.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)