Results 1 to 3 of 3

Thread: [RESOLVED] Combobox Variable designation

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2007
    Location
    St Charles, Mo
    Posts
    171

    Resolved [RESOLVED] Combobox Variable designation

    I am new to coding VB so bear with me. I am using VB 2005 Express. I am attempting to code up a small program to use as a calculator of sorts for a game I play, eve Online. I will have multiple calculations that will be done when the user fills in the information and presses the calculate button. I am trying to figure out the best way to go about doing this. So let me explain just what I am trying to do. The program will take an ore and run a calculation to see how much minerals it will give. There is 8 different minerals. Each ore gives off a certain amount of each of the 8 minerals. So I will run a calculation against each mineral for the amount of ore they have. Not really that hard but there is 47 different ores. Right now I am just trying to figure out one ore, then I can replicate it for the rest of them.

    So I have set up my combo box, called ore_01. The ore is called Arkonor. I have set up a public dim stating Public Arkonor As String. No under the combo box I have set up:
    Code:
    Dim ore_01_var As String
    ore_01_var = ore_01.Text
    One of the minerals the ore Arkonor gives is tritanium. So in the public section I have set up Public tritanium As Integer. This variable, tritanium, will have numeric value that will change based on the ore selected. So in the case of our ore Arkonor I set up an if statement in the combo box:
    Code:
     If ore_01_var = Arkonor Then
                tritanium = 300
            End If
    To test the use of my variable I created this in my calculate button to display our number.
    Code:
     tritanium_unit_value.Text = tritanium
    When I calculate it displays a 0 in the text box. It displays something but not the value I need. If I change the tritanium_unit_value.Text = tritanium to equal a number it will display the number. So there must be an issue with the translation of the variable. I am not really sure though. I am still learning at this point. Any suggestions one where to go?

    Thanks Spiffy

  2. #2
    Fanatic Member Jumpercables's Avatar
    Join Date
    Jul 2005
    Location
    Colorado
    Posts
    592

    Re: Combobox Variable designation

    Try adding .ToString()

    Code:
    tritanium_unit_value.Text = tritanium.ToString()

    C# - .NET 1.1 / .NET 2.0

    "Take everything I say with a grain of salt, sometimes I'm right, sometimes I'm wrong but in the end we've both learned something."
    _____________________
    Regular Expressions Library
    Connection String
    API Functions
    Database FAQ & Tutorial

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2007
    Location
    St Charles, Mo
    Posts
    171

    Re: Combobox Variable designation

    Well I muscled through it and some how got it working. I added in the public
    Code:
     Public Arkonor As String = "Arkonor"
    I did this for every item in my combobox. There is like 47 of them lol. Not sure if this is the correct way to do it but all the calculations are working.

    once that was done I put in a dim statement to say the variable for the combobox is a string so it matched the public entry I guess. Then I put in if statements with the variables I wanted for each of the entries in the combobox. It long but I think it is what it is supposed to be. here is an example.

    Code:
    If ore_01_var = "Arkonor" Then
                isogen_01 = 0
                megacyte_01 = 333
                mexallon_01 = 0
                morphite_01 = 0
                nocxium_01 = 0
                pyerite_01 = 0
                tritanium_01 = 300
                zydrine_01 = 166
                refine_amount_01 = 200
                ore_density_01 = 16
            End If
    So then when i do my calcs I use the variables listed above. it works out well since whatever the drop down is the value of my variable changed. I think I did it right anyway lol.

Posting Permissions

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



Click Here to Expand Forum to Full Width