dcsimg
Results 1 to 4 of 4

Thread: structured “integer” can not be index because it has no default property

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2018
    Posts
    3

    structured “integer” can not be index because it has no default property

    Private Sub calculate_Click (sender As Object, e As EventArgs) Handles calculate.Click
    Dim A As Double
    Dim Ek As Double
    Dim X As Double
    Dim Z As Double
    Dim Y As Double

    Dim five As Double = 5.0
    Dim two As Double = 2.0


    A = valueA.Text
    Ek = valueE.Text
    X = valueX.Text
    Z = valueZ.Text
    Y = Sqrt((valueX.Text ^ 2) - (five(valueZ.Text) / two(valueA.Text))) + Sin(valueX.Text) - Cos(valueZ.Text((valueX.Text ^ 3) - (valueE.Text ^ valueA.Text)))

    End Sub
    the variable five and two are the errors can someone pls help, thanks in advance

  2. #2
    Hyperactive Member
    Join Date
    Nov 2017
    Posts
    399

    Re: structured “integer” can not be index because it has no default property

    With traditional math operation notation, 5(5) implies 5*5.

    It doesn't work that way in coding. variablename(value) has a completely different meaning than variablename*value

    If you intend to multiply, you need to include the multiplication symbol.

    So instances where you have something like:

    Code:
    five(somevalue)
    it should be replaced by
    Code:
    five * (somevalue)
    Good luck.

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    32,377

    Re: structured “integer” can not be index because it has no default property

    Eventually, you're going to want to turn Option Strict ON and fix all the errors. For example, you implicitly converting the values from textboxes to put them in variables, but then you use the textboxes again in the calculation. Implicit conversions are slow and unsafe. You won't see the slow down in speed in this code, but you will see it if you leave a textbox empty. A better solution would be to use a NumericUpDown control rather than textboxes, as the NUD.Value is a Decimal already, and can always be converted safely to a Double. Then, once you've done the conversion to put the values into the variables, use the variables in the equation rather than going back to the controls to re-convert them.
    My usual boring signature: Nothing

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2018
    Posts
    3

    Re: structured “integer” can not be index because it has no default property

    Thanks all i have been able to solve it with your help

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width