hi im learning VB.NEt
im doing a game project where i have 4 animals racing
in my properties i have stamina, weight, height acceleration
all of them are in combo box with assigned values like "poor", "average", "fast" etc

my problem is i want to show the finishing time of my animals after the race, to do this i have to use a formula which i have:

RaceDistance= _stamina + _weight + _height + _acceleration

FinishingTime= _distance (which is also a combo box and have assigned values of :30, 50 80)/ RaceDistance


my problem is i dont know how to assign integer to the values of my combo boxes ("poor2 "average" etc)
to permit me to calculate them

i want to be able to do something like
AnmWeight.selectedItem= "heavy"
Weight= +0.5

as oppose to is animal is lighter:
AnmWeight.SelectedItem= "light"
Weight= +2


help please

>my problem is i dont know how to assign integer to the values of my combo boxes

Create a datatable instance having two columns.

Dim Dt as New System.Data.DataTable
 Dt.Columns.Add("Animal")
 Dt.Columns.Add("Weight")

 Dt.Rows.Add("heavy","3")
 .....

 ComboBox1.datasource=Dt
 ComboBox1.DisplayMember="Animal"
 ComboBox1.ValueMember="Weight"

Handle SelectedIndexChanged event of ComboBox1.

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Dim r As DataRowView = ComboBox1.SelectedItem
        If Not IsNothing(r) Then
            Label1.Text =r("Weight")
        End If
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.