Visual Basic Structures and Variables - vb.net

I'm working on this assignment where I need to have an array inside of a structure. The array consists of imported values from a text file:
2,3
3,4
4,4
5,5
5,4
6,3
3,6
9,9
10,10
1,5
2,5
3,5
1,4
2,4
3,4
4,4
I'm getting these errors:
Severity Code Description Project File Line Suppression State
Error BC30456 'real' is not a member of 'Form1.complexNumber()'. WindowsApplication3 e:\users\gabe\documents\visual studio 2015\Projects\Lab7_Gabriel_Carnes\WindowsApplication3\Form1.vb 68 Active
Severity Code Description Project File Line Suppression State
Error BC30311 Value of type 'Form1.complexNumber' cannot be converted to 'String'. WindowsApplication3 e:\users\gabe\documents\visual studio 2015\Projects\Lab7_Gabriel_Carnes\WindowsApplication3\Form1.vb 69 Active
I've tried moving the structure to be within a method instead of at form level but it then gives an error about not being able to be within a method.
Code:
Public Class Form1
Dim Real1, Real2, Imag1, Imag2 As Double
Dim Answer As String
Private Structure complexNumber
Public real As String
Public imag As String
End Structure
' Dim strValues() As fileInport =
' IO.File.ReadAllLines("Input.txt")
Dim Values(15) As complexNumber
Dim ValuesString As String
Dim line, data() As String
Dim inputs() As String =
IO.File.ReadAllLines("Input.txt")
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
lblBy.Visible = False
lblMinus.Visible = False
lblPlus.Visible = False
lblTimes.Visible = False
lblAnswer.Text = ""
For i As Integer = 0 To 15
line = inputs(i)
data = line.Split(","c)
Values(i).real = data(0)
Values(i).imag = data(1)
'Values(i) = (strValues(i))
Next
End Sub
'ALL TEXT FILE VALUE CALCULATIONS
Private Sub btnFileAdd_Click(sender As Object, e As EventArgs) Handles btnFileAdd.Click
'ComplexMath.MathFunctions.Add(Values(0).real, Values(0).imag, Values(1).real, Values(1).imag)
'lstFileResults.Items.AddRange = Values(15)
ValuesString = Values.real(15)
TextBox1.Text = Values(15)
lblBy.Visible = False
lblTimes.Visible = False
lblMinus.Visible = False
lblPlus.Visible = True
End Sub
Private Sub btnFileSubtract_Click(sender As Object, e As EventArgs) Handles btnFileSubtract.Click
lblBy.Visible = False
lblTimes.Visible = False
lblPlus.Visible = False
lblMinus.Visible = True
End Sub
Private Sub btnFileMultiply_Click(sender As Object, e As EventArgs) Handles btnFileMultiply.Click
lblBy.Visible = False
lblPlus.Visible = False
lblMinus.Visible = False
lblTimes.Visible = True
End Sub
Private Sub btnFileDivide_Click(sender As Object, e As EventArgs) Handles btnFileDivide.Click
lblTimes.Visible = False
lblPlus.Visible = False
lblMinus.Visible = False
lblBy.Visible = True
End Sub
'ALL USER VALUE CALCULATIONS
Private Sub btnUserAdd_Click(sender As Object, e As EventArgs) Handles btnUserAdd.Click
Real1 = Val(txtReal1.Text)
Real2 = Val(txtReal2.Text)
Imag1 = Val(txtImag1.Text)
Imag2 = Val(txtImag2.Text)
Answer = ComplexMath.MathFunctions.Add(Real1, Imag1, Real2, Imag2)
lblAnswer.Text = Answer
lblBy.Visible = False
lblTimes.Visible = False
lblMinus.Visible = False
lblPlus.Visible = True
End Sub
Private Sub btnUserSubtract_Click(sender As Object, e As EventArgs) Handles btnUserSubtract.Click
Real1 = Val(txtReal1.Text)
Real2 = Val(txtReal2.Text)
Imag1 = Val(txtImag1.Text)
Imag2 = Val(txtImag2.Text)
Answer = ComplexMath.MathFunctions.Subtract(Real1, Imag1, Real2, Imag2)
lblAnswer.Text = Answer
lblBy.Visible = False
lblTimes.Visible = False
lblPlus.Visible = False
lblMinus.Visible = True
End Sub
Private Sub btnUserMultiply_Click(sender As Object, e As EventArgs) Handles btnUserMultiply.Click
Real1 = Val(txtReal1.Text)
Real2 = Val(txtReal2.Text)
Imag1 = Val(txtImag1.Text)
Imag2 = Val(txtImag2.Text)
Answer = ComplexMath.MathFunctions.Multiply(Real1, Imag1, Real2, Imag2)
lblAnswer.Text = Answer
lblBy.Visible = False
lblPlus.Visible = False
lblMinus.Visible = False
lblTimes.Visible = True
End Sub
Private Sub btnUserDivide_Click(sender As Object, e As EventArgs) Handles btnUserDivide.Click
Real1 = Val(txtReal1.Text)
Real2 = Val(txtReal2.Text)
Imag1 = Val(txtImag1.Text)
Imag2 = Val(txtImag2.Text)
Answer = ComplexMath.MathFunctions.Multiply(Real1, Imag1, Real2, Imag2)
lblAnswer.Text = Answer
lblTimes.Visible = False
lblPlus.Visible = False
lblMinus.Visible = False
lblBy.Visible = True
End Sub
End Class

Related

Having issues writing the code for this problem in Visual Basic

This is the question I'm having difficulty figuring out. I'm unable to get splash screens to show up on my previous two questions I was able to complete the coding and design, but this one is throwing me for a loop.
This is what I have so far
Public Sub New()
InitializeComponent()
label2.Visible = False
label3.Visible = False
label4.Visible = False
comboBox1.Items.Add("Uber")
comboBox1.Items.Add("Subway")
comboBox1.Items.Add("Bus")
End Sub
Private Sub comboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
If comboBox1.SelectedIndex = 0 Then
label2.Visible = True
label3.Visible = True
label4.Visible = True
End If
If comboBox1.SelectedIndex = 1 Then
label2.Visible = True
label3.Visible = True
label4.Visible = False
End If
If comboBox1.SelectedIndex = 2 Then
label2.Visible = True
label3.Visible = True
label4.Visible = False
End If
End Sub

POPULATION OF TABLE FROM WINDOWS FORM

I am done with designing the windows form::
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ComboBox2.Visible = False
Label2.Visible = False
ComboBox3.Visible = False
Label3.Visible = False
ComboBox4.Visible = False
Label4.Visible = False
ComboBox5.Visible = False
Label5.Visible = False
DateTimePicker1.Visible = False
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
If (ComboBox1.Text = "BY-ELECTION") Then
ComboBox2.Visible = True
Label2.Visible = True
DateTimePicker1.Visible = False
ElseIf (ComboBox1.Text = "GENERAL ELECTION") Then
ComboBox2.Visible = False
Label2.Visible = False
ComboBox3.Visible = False
Label3.Visible = False
ComboBox4.Visible = False
Label4.Visible = False
ComboBox5.Visible = False
Label5.Visible = False
DateTimePicker1.Visible = True
End If
End Sub
Private Sub ComboBox4_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox4.SelectedIndexChanged
If ComboBox4.SelectedValue = "" And ComboBox2.Text = "MP" Then
DateTimePicker1.Visible = True
End If
If (ComboBox4.Text = "MVITA") And ComboBox2.Text = "MCA" Then
Label5.Visible = True
ComboBox5.Visible = True
ComboBox5.Items.Clear()
ComboBox5.Items.Add("MAJENGO")
ComboBox5.Items.Add("MAKADARA")
ComboBox5.Items.Add("SHIMANZI")
ComboBox5.Items.Add("TONONOKA")
ComboBox5.Items.Add("TUDOR")
DateTimePicker1.Visible = False
End If
End Sub
Private Sub ComboBox3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox3.SelectedIndexChanged
If (ComboBox3.Text = "MOMBASA") And ComboBox2.Text = "MP" Or (ComboBox3.Text = "MOMBASA") And ComboBox2.Text = "MCA" Then
Label4.Visible = True
ComboBox4.Visible = True
ComboBox4.Items.Clear()
ComboBox4.Items.Add("CHANGAMWE")
ComboBox4.Items.Add("JOMVU")
ComboBox4.Items.Add("KISAUNI")
ComboBox4.Items.Add("LIKONI")
ComboBox4.Items.Add("MVITA")
ComboBox4.Items.Add("NYALI")
End If
End Sub
Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
If ComboBox2.Text = "GOVERNORSHIP" Or ComboBox2.Text = "SENATOR" Then
Label3.Visible = True
ComboBox3.Visible = True
Label5.Visible = False
ComboBox5.Visible = False
DateTimePicker1.Visible = True
ComboBox4.Visible = False
Label4.Visible = False
ElseIf ComboBox2.Text = "MP" Or ComboBox2.Text = "MCA" Then
Label3.Visible = True
ComboBox3.Visible = True
DateTimePicker1.Visible = False
Label6.Visible = False
ComboBox4.Visible = False
Label4.Visible = False
ComboBox5.Visible = False
Label5.Visible = False
End If
End Sub
Private Sub ComboBox5_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox5.SelectedIndexChanged
Label6.Visible = True
DateTimePicker1.Visible = True
End Sub
and i am stuck at the command button.
My windows form has 5 combobox with items assigned to them but in this illustration i am going to use one item for example:
Combobox2 has item MCA
Combobox3(labeled COUNTY) has item MOMBASA
Combobox4(labeled CONSTITUENCY) has item MVITA
Combobox5(labeled WARD) has item SHIMANZI
I want if i select item MCA in combobox2 and click the button GENERATE a table:
will be created and saved in the path C:\Users\Administrator\Documents\ and populated in the following format
cell A2 = item selected in combobox3
cell B2= item selected in combobox4
cell C2=item selected in combobox5
cell H2 to be populated with random input be based on gender(male/female) and letters(ABCD only) in that order. ie cell H2= MALE,D
You can refer to the following code to generate DataTable.
Dim dt As DataTable = New DataTable
dt.Columns.Add("COUNTY")
dt.Columns.Add("CONSTITUENCY")
dt.Columns.Add("WARD")
dt.Rows.Add(ComboBox3.SelectedItem.ToString, ComboBox4.SelectedItem.ToString, ComboBox5.SelectedItem.ToString)
Then use the following code to export the data table to Excel:
Dim excelFilePath As String = "excel path"
Dim excelApp = New Excel.Application()
excelApp.Workbooks.Add()
Dim workSheet As Excel._Worksheet = excelApp.ActiveSheet
For i = 0 To dt.Columns.Count - 1
workSheet.Cells(1, i + 1) = dt.Columns(i).ColumnName
Next
For i = 0 To dt.Rows.Count - 1
For j = 0 To dt.Columns.Count - 1
workSheet.Cells(i + 2, j + 1) = dt.Rows(i)(j)
Next
Next
If Not String.IsNullOrEmpty(excelFilePath) Then
Try
workSheet.SaveAs(excelFilePath)
excelApp.Quit()
MessageBox.Show("Excel file saved!")
Catch ex As Exception
Throw New Exception("ExportToExcel: Excel file could not be saved! Check filepath." & vbLf & ex.Message)
End Try
End If
Result of the test looks like:

Adding images to Access Database Vb.net - Insert into syntax error

I'm quite new to Visual Basic. I'm developing a simple Student Registration System that has a profile of Students with a photo in it. I managed to get the image addition code online and I tried to figure it out and use it for my program. All is set except the sql insert statement that will insert the photo into the "Image" field of the "Students" table of my database. When I click the save button, I keep getting Insert into syntax error but I can't seem to figure out exactly what the error in the sql statement is. I would appreciate it if I can get help with it. This is the whole code for the profile but I have put a comment where the sql statement is so you can go straight there. Thanks and Thanks again
Imports System.IO
Imports System.Data.OleDb
Public Class Profile
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter
Dim sql As String
Dim conString As String
Dim inc As Integer
Dim maxrows As Integer
Dim dsNewRow As DataRow
Dim SID As String
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles txtNationality.SelectedIndexChanged
End Sub
Private Sub GroupBox1_Enter(sender As Object, e As EventArgs) Handles GroupBox1.Enter
End Sub
Private Sub ProfileRecords()
txtFirstName.Text = ds.Tables("StudentRegSYS").Rows(inc).Item(1)
txtMiddleName.Text = ds.Tables("StudentRegSYS").Rows(inc).Item(2)
txtLastName.Text = ds.Tables("StudentRegSYS").Rows(inc).Item(3)
txtGender.Text = ds.Tables("StudentRegSYS").Rows(inc).Item(4)
txtNationality.Text = ds.Tables("StudentRegSYS").Rows(inc).Item(5)
txtLevel.Text = ds.Tables("StudentRegSYS").Rows(inc).Item(6)
txtFaculty.Text = ds.Tables("StudentRegSYS").Rows(inc).Item(7)
txtProgramme.Text = ds.Tables("StudentRegSYS").Rows(inc).Item(8)
txtAcademicPeriod.Text = ds.Tables("StudentRegSYS").Rows(inc).Item(9)
txtDateRegistered.Text = ds.Tables("StudentRegSYS").Rows(inc).Item(10)
maxrows = ds.Tables("StudentRegSYS").Rows.Count
txtFirstName.ReadOnly = True
txtMiddleName.ReadOnly = True
txtLastName.ReadOnly = True
txtGender.Enabled = False
txtFaculty.Enabled = False
txtLevel.ReadOnly = True
txtNationality.Enabled = False
txtProgramme.Enabled = False
txtAcademicPeriod.ReadOnly = True
txtDateRegistered.ReadOnly = True
End Sub
Private Sub Profile_Load(sender As Object, e As EventArgs) Handles MyBase.Load
SID = Login.txtstudentid.Text
btneditcancel.Visible = False
btneditsave.Visible = False
btnbrowseimage.Visible = False
txtimagepath.Visible = False
Try
conString = "Provider = Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Yaw Biney\Documents\Visual Studio 2015\Projects\Student Registration System\Student Registration System\StudentRegSYS.accdb"
con = New OleDbConnection(conString)
con.Open()
sql = "select * from Students Where SID='" + SID + "'"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "StudentRegSYS")
con.Close()
Catch EXP As Exception
MessageBox.Show(EXP.ToString)
End Try
con.Open()
ProfileRecords()
txtNationality.Items.Add("Ghanaian")
txtNationality.Items.Add("Togolese")
txtNationality.Items.Add("Gabonese")
txtNationality.Items.Add("Ivorian")
txtNationality.Items.Add("Burkinabe")
txtNationality.Items.Add("Nigerian")
txtNationality.Items.Add("Beninois")
txtFaculty.Items.Add("Informatics")
txtFaculty.Items.Add("Engineering")
txtFaculty.Items.Add("Business")
txtProgramme.Items.Add("Bsc. Information Technology")
txtProgramme.Items.Add("Bsc. Telecom Engineering")
txtProgramme.Items.Add("Bsc. Computer Engineering")
txtProgramme.Items.Add("BA. Business Administration")
txtProgramme.Items.Add("Diploma in Information Technology")
txtProgramme.Items.Add("Diploma in Business Studies")
txtwelcomemsg.Text = "Welcome " & txtLastName.Text & ", " & txtFirstName.Text & " " & txtMiddleName.Text
End Sub
Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles txtMiddleName.TextChanged
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
btneditcancel.Visible = True
btneditsave.Visible = True
btnbrowseimage.Visible = True
txtimagepath.Visible = True
txtFirstName.ReadOnly = False
txtMiddleName.ReadOnly = False
txtLastName.ReadOnly = False
txtGender.Enabled = True
txtFaculty.Enabled = True
txtLevel.ReadOnly = False
txtNationality.Enabled = True
txtProgramme.Enabled = True
txtAcademicPeriod.ReadOnly = False
txtDateRegistered.ReadOnly = False
End Sub
Private Sub btneditcancel_Click(sender As Object, e As EventArgs) Handles btneditcancel.Click
btneditcancel.Visible = False
btneditsave.Visible = False
btnbrowseimage.Visible = False
txtimagepath.Visible = False
txtFirstName.ReadOnly = True
txtMiddleName.ReadOnly = True
txtLastName.ReadOnly = True
txtGender.Enabled = False
txtFaculty.Enabled = False
txtLevel.ReadOnly = True
txtNationality.Enabled = False
txtProgramme.Enabled = False
txtAcademicPeriod.ReadOnly = True
txtDateRegistered.ReadOnly = True
End Sub
Private Sub btneditsave_Click(sender As Object, e As EventArgs) Handles btneditsave.Click
Dim cb As New OleDb.OleDbCommandBuilder(da)
Try
ds.Tables("StudentRegSYS").Rows(inc).Item(1) = txtFirstName.Text
ds.Tables("StudentRegSYS").Rows(inc).Item(2) = txtMiddleName.Text
ds.Tables("StudentRegSYS").Rows(inc).Item(3) = txtLastName.Text
ds.Tables("StudentRegSYS").Rows(inc).Item(4) = txtGender.Text
ds.Tables("StudentRegSYS").Rows(inc).Item(5) = txtNationality.Text
ds.Tables("StudentRegSYS").Rows(inc).Item(6) = txtLevel.Text
ds.Tables("StudentRegSYS").Rows(inc).Item(7) = txtFaculty.Text
ds.Tables("StudentRegSYS").Rows(inc).Item(8) = txtProgramme.Text
ds.Tables("StudentRegSYS").Rows(inc).Item(9) = txtAcademicPeriod.Text
ds.Tables("StudentRegSYS").Rows(inc).Item(10) = txtDateRegistered.Text
da.Update(ds, "StudentRegSYS")
MessageBox.Show("Profile updated successfully")
Catch ex As Exception
MessageBox.Show("Error: " & ex.ToString())
End Try
'Error seems to be from here on going'
Try
Dim MemStream As New MemoryStream
Dim DataPic_Update As Byte()
Me.picboxprofilepic.Image.Save(MemStream, Imaging.ImageFormat.Jpeg)
DataPic_Update = MemStream.GetBuffer()
MemStream.Read(DataPic_Update, 0, MemStream.Length)
Dim cmd As OleDbCommand = New OleDbCommand("INSERT INTO Students (Image) VALUES(#Image)", con)
Dim photo As OleDbParameter = New OleDbParameter("#Image", SqlDbType.Image)
photo.Value = DataPic_Update
cmd.Parameters.Add(photo)
cmd.ExecuteNonQuery()
MessageBox.Show("Record Is Added")
Catch ex As Exception
MessageBox.Show("Error: " & ex.ToString())
End Try
btneditcancel.Visible = False
btneditsave.Visible = False
btnbrowseimage.Visible = False
txtimagepath.Visible = False
txtFirstName.ReadOnly = True
txtMiddleName.ReadOnly = True
txtLastName.ReadOnly = True
txtGender.Enabled = False
txtFaculty.Enabled = False
txtLevel.ReadOnly = True
txtNationality.Enabled = False
txtProgramme.Enabled = False
txtAcademicPeriod.ReadOnly = True
txtDateRegistered.ReadOnly = True
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Change_Password.Show()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnbrowseimage.Click
OpenFileDialog1.Filter = "jpeg|*.jpg|bmp|*.bmp|all files|*.*"
If OpenFileDialog1.ShowDialog = System.Windows.Forms.DialogResult.OK Then
Me.picboxprofilepic.Image = System.Drawing.Image.FromFile(OpenFileDialog1.FileName)
txtimagepath.Text = OpenFileDialog1.FileName
End If
End Sub
End Class

How to write a common code to display many picturebox in vb.net 2.0 ?

Imports System.Threading.Thread
Public Class Form1
Dim delay As Integer = 200
Dim i As Integer = 1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
While i <= 5
PictureBox1.Visible = True
PictureBox1.Refresh()
Sleep(delay)
PictureBox1.Visible = False
PictureBox2.Visible = True
PictureBox2.Refresh()
Sleep(delay)
PictureBox2.Visible = False
PictureBox3.Visible = True
PictureBox3.Refresh()
Sleep(delay)
PictureBox3.Visible = False
PictureBox4.Visible = True
PictureBox4.Refresh()
Sleep(delay)
PictureBox4.Visible = False
PictureBox5.Visible = True
PictureBox5.Refresh()
Sleep(delay)
PictureBox5.Visible = False
i = i + 1
If i = 6 Then
i = 1
End If
End While
End Sub
i wrote the above code. it's working. but the following code is not not working. i want to minimize the code. i want to use 20 picture box. instead of the above code i want to use small code but it will do the same work. please help me.
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
While i <= 5
Dim pic As PictureBox
Dim matches() As Control
matches = Me.Controls.Find("PictureBox" & i.ToString(), True)
If matches.Length > 0 AndAlso TypeOf matches(0) Is Label Then
pic = DirectCast(matches(0), PictureBox)
pic.Visible = True
pic.Refresh()
Sleep(delay)
pic.Visible = False
End If
i = i + 1
If i = 6 Then
i = 1
End If
End While
End Sub
End Class
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
While i <= 5
Dim pic As PictureBox
Dim matches() As Control
matches = Me.Controls.Find("PictureBox" & i.ToString(), True)
If matches.Length > 0 AndAlso TypeOf matches(0) Is PictureBox Then
pic = DirectCast(matches(0), PictureBox)
pic.Visible = True
pic.Refresh()
Wait(delay)
pic.Visible = False
End If
i = i + 1
If i = 6 Then
i = 1
End If
End While
End Sub
this code is correct... sorry i wrote wrong code 1st time.. now it's correct.. thank u all..

Trouble With State/Capital Matching Program In VB

Alright, so the program is set up where you have a set of radio buttons with 5 states, and another set of 5 with 5 capitals. There's a button which tells you if they match or not. However I have to do it a certain way where clicking a radio button assigns a variable to both 'strCapital' and 'strChoice' and you compare them to see if they match.
I've tried to figure everything out (since it sounds easy in theory) but I've hit a wall.
Option Explicit On
Option Strict On
Option Infer Off
Public Class frmMain
Dim strCapital As String
Dim strChoice As String
Dim strLittleRock As String
Dim strSpringfield As String
Dim strFrankfort As String
Dim strSalem As String
Dim strMadison As String
Private Sub radArkansas_CheckedChanged(sender As Object, e As EventArgs) Handles radArkansas.CheckedChanged
strCapital = strLittleRock
End Sub
Private Sub radIllinois_CheckedChanged(sender As Object, e As EventArgs) Handles radIllinois.CheckedChanged
strCapital = strSpringfield
End Sub
Private Sub radSpringfield_CheckedChanged(sender As Object, e As EventArgs) Handles radSpringfield.CheckedChanged
strChoice = strSpringfield
End Sub
Private Sub btnVerify_Click(sender As Object, e As EventArgs) Handles btnVerify.Click
If strCapital = strChoice Then
lblMsg.Text = "Correct"
ElseIf strCapital <> strChoice Then
lblMsg.Text = "Incorrect"
End If
End Sub
Private Sub radLittleRock_CheckedChanged(sender As Object, e As EventArgs) Handles
radLittleRock.CheckedChanged
strChoice = strLittleRock
End Sub
End Class
EDIT: Also I forgot to mention the main problem which is always a bad thing. Basically whenever I run it and enter something incorrect (checking Arkansas and Springfield for example) it always says it's correct.
I did something similar... you can modify this code:
Private Sub btnAmIRight_Click(sender As Object, e As EventArgs) Handles btnAmIRight.Click
' displays if submission is correct
' declare variables
Dim strAmIRight As String
Dim dblMatch As Double
If rbtnAlabama.Checked = True And rbtnMontgomery.Checked = True Then
dblMatch = 1
ElseIf rbtnAlaska.Checked = True And rbtnJuneau.Checked = True Then
dblMatch = 1
ElseIf rbtnArizona.Checked = True And rbtnPhoenix.Checked = True Then
dblMatch = 1
ElseIf rbtnArkansas.Checked = True And rbtnLittleRock.Checked = True Then
dblMatch = 1
ElseIf rbtnCalifornia.Checked = True And rbtnSacramento.Checked = True Then
dblMatch = 1
ElseIf rbtnColorado.Checked = True And rbtnDenver.Checked = True Then
dblMatch = 1
ElseIf rbtnConnecticut.Checked = True And rbtnHartford.Checked = True Then
dblMatch = 1
ElseIf rbtnDelaware.Checked = True And rbtnDover.Checked = True Then
dblMatch = 1
ElseIf rbtnFlorida.Checked = True And rbtnTallahassee.Checked = True Then
dblMatch = 1
ElseIf rbtnGeorgia.Checked = True And rbtnAtlanta.Checked = True Then
dblMatch = 1
Else
dblMatch = 0
End If
' assign code to variable
If dblMatch = 1 Then
strAmIRight = "Correct"
ElseIf dblMatch = 0 Then
strAmIRight = "Try Again"
End If
' display result
lblResult.Text = strAmIRight.ToString
End Sub