Results 1 to 4 of 4

Math Help - vb calculation formula problem

  1. #1
    Newbie
    Joined
    Aug 2009
    Posts
    2

    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
    Pim is offline
    Member
    Joined
    Dec 2008
    From
    The Netherlands
    Posts
    91
    I don't understand your first question, but your second can be solved like this:

    Code:
     
    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
    Newbie
    Joined
    Sep 2009
    Posts
    7
    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
    Newbie
    Joined
    Nov 2009
    From
    HUntington Beach CA
    Posts
    6
    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

    Try
    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
    Context.Response.Write(A.ToString)
    Else
    Context.Response.Write(ErrorMessage)
    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: April 10th 2011, 05:29 AM
  2. Replies: 8
    Last Post: September 5th 2010, 12:11 PM
  3. Replies: 5
    Last Post: April 10th 2009, 02:57 AM
  4. Calculation Problem
    Posted in the Trigonometry Forum
    Replies: 11
    Last Post: January 17th 2009, 08:31 PM
  5. Percentage Calculation Problem
    Posted in the Statistics Forum
    Replies: 1
    Last Post: November 3rd 2008, 03:32 AM

Search Tags


/mathhelpforum @mathhelpforum