lake54
Member
- Joined
- Sep 30, 2009
- Messages
- 6
- Programming Experience
- Beginner
Hi all,
I'm good with PCs in general, so I'm not a total noob, but I've only just started learning Visual Basic .NET for A Levels.
Part of this week's 'homework' was to write a particular program that does such and such - won't bore you with the details, but please don't think I'm "one of those" that just pass on the homework to a random forum - I've been a geek too long to recognise that that doesn't get anyone anywhere.
So, the question and the details:
I've got two list boxes on a standard form - one listing cities, the other capitals.
If the user selects the correct combo, and presses a check button, a standard msg box is displayed with congrats etc.
If the user selects the wrong combo, another msg box is displayed with a Yes No selection, to the question of if they want to have the correct answer selected for them.
Now, I've got everything working apart from this last part - having the correct answer selected. Here's the snippet of one of the If parts.
Just a word of warning - yes, it'll obviously be 'messy' and probably 'wrong' to anyone who is even half decent at VB.NET, but I've only just started, and it works for me, so that's all for now
Where I have the 'Select' bit, that was the last thing I tried, from another post on this forum: http://www.vbdotnetforums.com/windows-forms/14372-messagebox-buttons-result.html
but I don't quite know where to put the command I want carried out.
I've tried loads of different things to no success, such as instead of 'Case' I've tried If commands with
Please could I have some guidance on how to detect what the response was on a message box, and how to act on the response depending on whether it was a Yes or a No?
Just want to stress again - I haven't given up at the first hurdle - I've been trying to figure this out for well over an hour (probably more) now. Whatever combination I try seems to be wrong - when I press Yes it just stays on the currently selected item.
A massive thank you for any help anyone can provide.
James
I'm good with PCs in general, so I'm not a total noob, but I've only just started learning Visual Basic .NET for A Levels.
Part of this week's 'homework' was to write a particular program that does such and such - won't bore you with the details, but please don't think I'm "one of those" that just pass on the homework to a random forum - I've been a geek too long to recognise that that doesn't get anyone anywhere.
So, the question and the details:
I've got two list boxes on a standard form - one listing cities, the other capitals.
If the user selects the correct combo, and presses a check button, a standard msg box is displayed with congrats etc.
If the user selects the wrong combo, another msg box is displayed with a Yes No selection, to the question of if they want to have the correct answer selected for them.
Now, I've got everything working apart from this last part - having the correct answer selected. Here's the snippet of one of the If parts.
Just a word of warning - yes, it'll obviously be 'messy' and probably 'wrong' to anyone who is even half decent at VB.NET, but I've only just started, and it works for me, so that's all for now
VB.NET:
ElseIf lstCountry.SelectedIndex() = 4 Then
If lstCapital.SelectedIndex() = 0 Then
MessageBox.Show("You got it right!", "Correct!", MessageBoxButtons.OK)
Else
Select Case MessageBox.Show("You got it wrong - do you want to see what the correct answer was?", _
"Sorry!", MessageBoxButtons.YesNo, MessageBoxIcon.Error)
Case DialogResult.Yes
lstCapital.SelectedItem = 0
End Select
End If
Where I have the 'Select' bit, that was the last thing I tried, from another post on this forum: http://www.vbdotnetforums.com/windows-forms/14372-messagebox-buttons-result.html
but I don't quite know where to put the command I want carried out.
I've tried loads of different things to no success, such as instead of 'Case' I've tried If commands with
VB.NET:
ElseIf lstCountry.SelectedIndex() = 4 Then
If lstCapital.SelectedIndex() = 0 Then
MessageBox.Show("You got it right!", "Correct!", MessageBoxButtons.OK)
Else
MessageBox.Show("You got it wrong - do you want to see what the correct answer was?", _
"Sorry!", MessageBoxButtons.YesNo, MessageBoxIcon.Error)
If DialogResult = Windows.Forms.DialogResult.Yes Then
lstCapital.SelectedItem = 0
End If
End If
Please could I have some guidance on how to detect what the response was on a message box, and how to act on the response depending on whether it was a Yes or a No?
Just want to stress again - I haven't given up at the first hurdle - I've been trying to figure this out for well over an hour (probably more) now. Whatever combination I try seems to be wrong - when I press Yes it just stays on the currently selected item.
A massive thank you for any help anyone can provide.
James
Last edited: