Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

the program

  • 19-11-2002 9:45am
    #1
    Registered Users, Registered Users 2 Posts: 446 ✭✭


    The program is basically supposed to be a simple one where by
    the user enters there name and phone number then chooses the course options from the list box and combo box's for location etc.

    then they click confirm... then they click next if they want to add another course.

    It just has to tell them how many people are enrolled on each course however I cant do that so I was just going to add 1 everytime they click confirm and just have the enrolment for people in the college.

    Then! When the user has finished they press calculate and the final cost of all courses is calculated..and this is where I get really confused: the program has to calculate numbers but I'm not allowed to use Variables because Its too advanced aparently...but theres no other way is there?


Comments

  • Registered Users, Registered Users 2 Posts: 1,997 ✭✭✭The_Bullman


    why do i get the feeling that you clicked new thread instead of post reply :)


  • Registered Users, Registered Users 2 Posts: 6,240 ✭✭✭hussey


    Using variables is too advanced??
    surely you Have to use variables??
    I dont think you can do this by not having some kind of counter


  • Registered Users, Registered Users 2 Posts: 446 ✭✭kegan5


    I said that..the only thing I can think of is having hidden labels and sending the info there?

    I've no idea maybe I'm supposed to wiggle my fingers and produce some magic dust or something!
    Anyway...Heres the code I have so far... its the next button that doesnt work... it runs but doesnt add 1.

    _______________________-
    Private Sub cmdConfirm_Click()
    lblResult.Caption = "Name: " & txtName.Text & vbCrLf & "Address: " & txtAddress.Text & vbCrLf & "Phone Number: " & txtPhone.Text
    If list.Visible = True Then
    lblCost.Caption = "Course cost: €100"

    Else
    End If
    If optYes.Value = True Then
    lblPractical.Caption = "Practical Fee €15"
    Else
    If optNo.Value = True Then
    lblPractical.Caption = "No Practical Option Chosen"
    End If
    End If
    If cmbArea.ListIndex = 0 Then
    lblPractical.Caption = "Location: IT Carlow"
    Else
    If cmbArea.ListIndex = 1 Then
    lblPractical.Caption = "Location: Wexford It"
    Else
    Dim Other As String
    Other = txtOther.Text
    lblPractical.Caption = "Location: " & Other
    End If
    End If
    End Sub

    Private Sub cmdNext_Click()
    Dim Num As Integer
    intX = 0

    MsgBox "The number if people enrolled on this course is " & Num
    Num = intX + 1

    End Sub


    Private Sub Form_Load()
    intX = 0
    End Sub


  • Registered Users, Registered Users 2 Posts: 1,391 ✭✭✭fatherdougalmag


    I assume that intX is a global variable. If this is the case, every time the user clicks Next you set intX to 0. Num is only a local variable and is presumably initialised to 0 by VB so it would appear that Num is always zero. Because
    Num = intX + 1
    would be the same as
    Num = 0 + 1

    Also, because Num gets destroyed when you leave your Next handler, the next time the user clicks Next, it gets re-created and set to 0. IntX is then set to zero again and you're back in the same place you where.

    Private Sub cmdNext_Click()
    Dim Num As Integer
    intX = 0

    MsgBox "The number if people enrolled on this course is " & Num
    Num = intX + 1

    End Sub

    My guess is that Num = intX + 1 should be intX = intX + 1 so IntX gets incremented every time. You should also use intX in your message box instead of Num and just get rid of Num altogether.

    How's everyone in Carlow? I served my time down there and did a little lecturing when doing my MSc. Standards have obviously dropped since then :)


  • Moderators, Home & Garden Moderators, Regional Midwest Moderators, Regional West Moderators Posts: 16,724 Mod ✭✭✭✭yop


    Try this

    Option Explicit

    Dim intX As Integer


    Private Sub cmdConfirm_Click()
    lblResult.Caption = "Name: " & txtName.Text & vbCrLf & "Address: " & txtAddress.Text & vbCrLf & "Phone Number: " & txtPhone.Text
    If List.Visible = True Then
    lblCost.Caption = "Course cost: €100"

    Else
    End If
    If optYes.Value = True Then
    lblPractical.Caption = "Practical Fee €15"
    Else
    If optNo.Value = True Then
    lblPractical.Caption = "No Practical Option Chosen"
    End If
    End If
    If cmbArea.ListIndex = 0 Then
    lblPractical.Caption = "Location: IT Carlow"
    Else
    If cmbArea.ListIndex = 1 Then
    lblPractical.Caption = "Location: Wexford It"
    Else
    Dim Other As String
    Other = txtOther.Text
    lblPractical.Caption = "Location: " & Other
    End If
    End If
    End Sub

    Private Sub cmdNext_Click()

    intX = intX + 1
    MsgBox "The number if people enrolled on this course is " & intX


    End Sub


    Private Sub Form_Load()
    intX = 0
    End Sub


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 446 ✭✭kegan5


    These just have a static number it doesnt go up?

    I can do it in my head but without the loop it doesnt work..

    e.g

    Do While intX <=10

    Num = intX + 2
    msgBox("people= " &Num)
    Loop
    End sub.


    this works but obviously keeps looping ten times over then thats it... I cant think of any more conditions that would allow the user to use the rest of the program and the counter still be running in the background


  • Closed Accounts Posts: 5,564 ✭✭✭Typedef


    Private Sub cmdNext_Click()
    static intX

    intX = intX + 1
    MsgBox "The number if people enrolled on this course is " & cstr(intX)


    End Sub


    *monies in brown paper envelope care of bouvale property developments


  • Moderators, Home & Garden Moderators, Regional Midwest Moderators, Regional West Moderators Posts: 16,724 Mod ✭✭✭✭yop


    Sorry but you have us totally lost,

    As far as I can see what you wanted that when they clicked confirm that this would add the details, then click next and it would tell u that there was 1 person added.

    Then u add more details, then click confirm to add them to the label.
    Then you clicked next and it told u that there were 2 people added.

    the code u gave me did not do this, the code I gave u does.

    Where u are off to with the loops I cannot figure out, why are you counting down 10 people when there are only 2 added!!!


  • Moderators, Home & Garden Moderators, Regional Midwest Moderators, Regional West Moderators Posts: 16,724 Mod ✭✭✭✭yop


    Typedef - Gave that but I am afraid it is not what they want, so they reckon!!

    I am totally lost as to what they want!!


  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    Originally posted by kegan5
    I said that..the only thing I can think of is having hidden labels and sending the info there?

    Alternately, you could add the "result" string to a listbox or grid (instead of putting it in several labels as you're doing now), and simply retrieve the number of rows in listbox/grid when you need to give the total.

    Incidentally, if you're not allowed to use variables, then you have to use controls to store your info.

    As an alternate, which is *very* sneaky....use the Tag property of any control to store your values. They're not variables, but they're not used by the controls...they're there for any "user-specific" purposes you may want...

    jc


  • Advertisement
  • Closed Accounts Posts: 5,564 ✭✭✭Typedef


    I wonder what bonkey's answer to the Kobayashi Maru problem is?


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    If variables are too complex it's possible that is on the next class/chapter and they probably want something like.

    input "Number 1 (Type 10):"; a
    input "Number 2 (Type 20):"; b
    
    print 10 + 20
    
    

    Just because it has four legs and a tail doesn't make it a Zebra.

    Btw, can everyone PLEASE use the {CODE} tag (as above)


Advertisement