Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2005
    Location
    Burlington, VT
    Posts
    181

    I think I'm missing something simple

    Ok so I have a huge array declaring the atomic masses of elements and then this code:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim amu As Double = elements(ComboBox1.SelectedIndex + 1)
    'If AMUs to Moles is selected
    If convertfactor.SelectedIndex = 0 Then
    'Compute weight in grams
    Dim gweight As Long = amu * 1.66E-23
    Dim mols As Long = gweight / amu
    TextBox2.Text = mols

    combobox1 is what selects the element. I don't know what I'm missing but the answer ia always zero.

  2. #2
    Join Date
    Mar 2003
    Location
    Colorful Colorado
    Posts
    1,096
    Dim gweight As Long = amu * 1.66E-23
    1.66e-23 is so small that the result of the product is very small (unless amu is huge) then when you put it into a Long type it will round to zero. You probably don't want to be using the integer type of LONG.
    Chuck
    Digital Spectra
    (rendering with pixels)

Posting Permissions

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