473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Reverting value to previous after toggle is deselected

Hello

I'm developing a form that allows students to choose university module choices. I have a credit counter which keeps a running total of all selected modules credits. A module cannot be selected if it exceeds the credit limit for each semester.

One module is 'Management Dissertation' which is either worth 10 credits in semester 1 and 20 credits in semester 2 OR 20 credits in semester 1 and 10 credits in semester 2. Upon clicking the module, a yes/no/cancel msgbox appears asking which option they'd like - it updates the credits counter accordingly. However, I'm struggling to find a way of deducting those credits if the module is deselected.

This is my code so far - any thoughts?

'Management Dissertation

Private Sub mandistog_click()

Dim Response3
Dim Sem1CredVal As Integer
Dim Sem2CredVal As Integer

If ManDisTog.Value = True Then
Response3 = MsgBox("Management Dissertation can be counted as EITHER:" & Chr(13) & "a) 10 credits in Semester One and 20 credits in Semester Two" & Chr(13) & "OR" & Chr(13) & "b) 20 credits in Semester One and 10 credits in Semester Two" & Chr(13) & Chr(13) & "Click 'Yes' for option a) or 'No' for option b)", 35, "ALERT")
Select Case Response3

Case 6
Sem1CredVal = 10
Sem2CredVal = 20
If Sem1Cred.Value + Sem1CredVal <= Sem1TotCred.Value Then
Sem1Cred.Value = Sem1Cred.Value + Sem1CredVal
If Sem2Cred.Value + Sem2CredVal <= Sem2TotCred.Value Then
Sem2Cred.Value = Sem2Cred.Value + Sem2CredVal
Else
Call MsgBox("You cannot select more than a total of " & Sem2TotCred.Value & " credits in semester 2", vbExclamation, "ERROR")
ManDisTog.Value = False
End If
Else
Call MsgBox("You cannot select more than a total of " & Sem1TotCred.Value & " credits in semester 1", vbExclamation, "ERROR")
ManDisTog.Value = False
End If

Case 7
Sem1CredVal = 20
Sem2CredVal = 10
If Sem1Cred.Value + Sem1CredVal <= Sem1TotCred.Value Then
Sem1Cred.Value = Sem1Cred.Value + Sem1CredVal
If Sem2Cred.Value + Sem2CredVal <= Sem2TotCred.Value Then
Sem2Cred.Value = Sem2Cred.Value + Sem2CredVal
Else
Call MsgBox("You cannot select more than a total of " & Sem2TotCred.Value & " credits in semester 2", vbExclamation, "ERROR")
ManDisTog.Value = False
End If
Else
Call MsgBox("You cannot select more than a total of " & Sem1TotCred.Value & " credits in semester 1", vbExclamation, "ERROR")
ManDisTog.Value = False
End If

Case 2
ManDisTog.Value = False

End Select

End If

End Sub
Dec 23 '16 #1
1 742
PhilOfWalton
1,430 Expert 1GB
Have you thought of using check boxes and assigning the Credit values depending on which (if any) are chosen. In your code have a variable called "ErrorCondition" which gets set every time one of the checkboxes is updated, and gets unset only if the credits are within your limits. If the ErrorCondition persists, clear the check boxes and the student has to go round the loop again.

Phil
Dec 26 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: george | last post by:
Can anyone help? I query a database and return a result on the column "reference". There might be 7 listings. Each row is displayed in a table, with links through to a detail page. I am working...
0
by: audipen | last post by:
Hi, I've facing a certain problem with selected item in the ClassView. Basically here is what I do - When the user right-clicks on an item in the ClassView ,he can select a pop-up menu...
1
by: Andy Wells | last post by:
I'm using VB.NET and I have an application that binds a schema to the main form's controls, and the user has the ability to load an XML file through the schema and into the bound form. My...
2
by: ross kerr | last post by:
Hi all, I have a control that extends the ComboBox object. It updates the selected item based on what the user enters in the text area. In the OnLeave event of the combobox, the selected...
2
by: Juan Manuel Formoso | last post by:
Hi, I have a custom made toggle button, and I want to change the cursor in my application when it's pressed. I set the Cursor.Current property whenever that state changes, but on mouseup it...
2
by: Don Tucker | last post by:
Sorry, I attempted to tab in the previous post and accidentally posted prematurely. I am trying to use the WebBrowser control from Visual Studio 2005 to load a web page and display its HTML...
4
by: deko | last post by:
Basic question about checking the value of Toggle/Check/Combo/OptionGroups.... Checking like this: If Me!chkCheckBox Then ... End If and like this:
2
by: newfie912 | last post by:
I have an online application used for grading students. On one of the pages, I have a table with two rows and each row has 16 cells. The upper row contains the letter grade (A, A-, B+, B, etc)...
3
by: md9108 | last post by:
I have a previous page and next page coded. The next page works. The previous page gives me an http: 404 error and I can't figure it out. The error is on the line "<td align=left> <!-- ...
1
by: venkatn | last post by:
Hi, I just starting learning javascript by myself and have quick question if anyone can help. I already checked recent post and couldn't find any similar one. To get value of different check boxes...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.