Results 1 to 5 of 5
  1. #1
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85

    Calculate Grade

    I have a form that contains following:
    text box called "GBox"
    text box called "CalGrade"
    Button called "Button1"


    Button called "Reset"

    I am wanting to key in a numeric grade in GBox, click on Button1 and a letter grade appear in CalGrade.

    Here is what I have so far:
    PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim GBox AsInteger
    Dim CalGrade AsString
    If GBox >= 90 Then
    CalGrade = "A"
    ElseIf GBox >= 80 Then
    CalGrade = "B"
    ElseIf GBox >= 70 Then
    CalGrade = "C"
    ElseIf GBox >= 60 Then
    CalGrade = "D"
    Else : CalGrade = "F"
    EndIf
    EndSub

    can someone help.
    Thanks.

  2. #2
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    Remove the Dim GBox as integer and Calgrade as String lines. They cause Access to use local (to the sub) variables called GBox and Calgrade instead of the form Text Boxes.

    You can do away with Button1 by putting your code in the After Update event of Gbox, so that the Calgrade text box will be updated automatically each time you tyoe a value in GBox.

    John

  3. #3
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    I am actually writing this in VB Studio.
    Removing those causes error.

    Can you help?

  4. #4
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Sorry, no. I'm not very familiar with at. I was wondering what the odd syntax on the first line was!

    J.

  5. #5
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85
    ok thanks.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Calculate Interest
    By jgelpi16 in forum Queries
    Replies: 3
    Last Post: 08-19-2016, 08:01 PM
  2. How to calculate?
    By cap.zadi in forum Queries
    Replies: 1
    Last Post: 11-09-2011, 07:29 AM
  3. calculate value from two tables
    By victor in forum Programming
    Replies: 3
    Last Post: 08-20-2010, 12:13 PM
  4. Replies: 5
    Last Post: 05-05-2010, 04:31 PM
  5. calculate holidays
    By barkarlo in forum Queries
    Replies: 0
    Last Post: 12-20-2006, 06:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums