Results 1 to 4 of 4

Thread: vb calculation formula problem

  1. #1
    Aug 2009

    vb calculation formula problem

    my problems goes like this:

    1. Input the value of T:3
    Input the value of S: 6

    Then when i click the compute button the formula will compute like this

    T^S - [T(T-1)^S] + [T(T-2)^S] = A(answer)

    for example if i input T=3 and S=6 the computation will goes like this...

    3^6 - [3 (2)^6 ] + [3 (1)^6] =
    729 - 192 + 3 = 540

    ^ = raised to the power

    problem: a.) how can i decrement the value of T depending on the values i input
    b.) how can i make an alternate conditional statement of the - and + operation.. because the formula will be
    using an alternate operation - + - + and so on...

    visual basic please thnx

    hope someone can help me thank u very much
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Pim is offline
    Dec 2008
    The Netherlands
    I don't understand your first question, but your second can be solved like this:

    For i = c1 To c2 Step 2
    var1 += ....
    var1 -= ....
    Next i
    where i is a looping variable, which you can use in calculating var1. c1 and c2 are constants and var1 is a variable.

    Hope this helped.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Sep 2009
    um, PM me and tomorrow I can help you more. I saw this as I was getting ready for bed and I can give you the VB you need.

    first: I assume your using the dev environment right? so your making this into a form?
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Nov 2009
    HUntington Beach CA
    I got 541.
    I'm just doing this for practice because I need to learn how to do real math. I'm not not educated in reading math formula's and translating it to code, but I know how to write code. I did not understand decrement of T, and what the condition for it is. Anyways, this is just a 10 minute stab at it. Its made for the web, and not windows. For Windows, it's Console.Writeline(A)

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    If Not Page.IsPostBack Then

    CalculateST(3, 6)

    End If

    End Sub
    Public Function CalculateST(ByVal T As Long, ByVal S As Long) As Long

    Dim Success As Boolean = False
    Dim ErrorMessage As String = Nothing
    Dim Context As HttpContext = HttpContext.Current

    Dim Formula As Integer = 0
    Dim A As Long = 0

    If T > 2 Then Formula = 1

    Select Case Formula
    Case 1
    A = T ^ S - (T * (T - 1) - 1 ^ S) + (T * (T - 2 ^ S))
    Case 2
    A = T ^ S - (T * (T - 1) - 1 ^ S) + (T * (T - 2 ^ S))
    End Select

    Success = True

    Catch ex As Exception
    Success = False
    ErrorMessage = ex.Message.ToString

    End Try

    If Success = True Then
    End If

    End Function
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. calculation problem
    Posted in the Algebra Forum
    Replies: 4
    Last Post: Apr 10th 2011, 05:29 AM
  2. Replies: 8
    Last Post: Sep 5th 2010, 12:11 PM
  3. Replies: 5
    Last Post: Apr 10th 2009, 02:57 AM
  4. Calculation Problem
    Posted in the Trigonometry Forum
    Replies: 11
    Last Post: Jan 17th 2009, 08:31 PM
  5. Percentage Calculation Problem
    Posted in the Statistics Forum
    Replies: 1
    Last Post: Nov 3rd 2008, 03:32 AM

Search Tags

/mathhelpforum @mathhelpforum