I've done the following code but I can't figure out how to get an output to come out;
I used a structure to store both strings and doubles, and then created an array using that datatype.
However I can't work out how to create an output. It wont let me convert either so I haven't figured this out. Any tips would be appreciated.
Public Class Form1
Structure Salestaff 'Created a Salestaff structure in order to have more than one datatype and call them
Dim Name As String
Dim Sales As Double
Dim Salary As Double
End Structure
Dim Staff(3) As Salestaff 'Array for staff
Const Commission As Double = 0.015
Const Base As Double = 450
Dim Salary As Double
Dim DisplaySales As String
Private Sub btnAddsales_Click(sender As System.Object, e As System.EventArgs) Handles btnAddsales.Click
If lstStaff.SelectedItem = "John King" Then
Staff(0).Name = "John King"
Staff(0).Sales = Val(txtSales.Text)
Staff(0).Salary = Base + (Commission * Staff(0).Sales) 'Should apply formula
ElseIf lstStaff.SelectedItem = "David Smith" Then
Staff(1).Name = "David Smith"
Staff(1).Sales = Val(txtSales.Text)
Staff(1).Salary = Base + (Commission * Staff(1).Sales)
ElseIf lstStaff.SelectedItem = "Tim Cook" Then
Staff(2).Name = "Tim Cook"
Staff(2).Sales = Val(txtSales.Text)
Staff(2).Salary = Base + (Commission * Staff(2).Sales)
ElseIf lstStaff.SelectedItem = "Ewan McDonnell" Then
Staff(3).Name = "Ewan McDonnell"
Staff(3).Sales = Val(txtSales.Text)
Staff(3).Salary = Base + (Commission * Staff(3).Sales)
End If
End Sub
Function DisplayStaff() 'Should take Staff info and allow it to be outputted
Dim Staffreport As String
Staffreport = Staff
Return Staffreport
End Function
Private Sub btnDisplay_Click(sender As System.Object, e As System.EventArgs) Handles btnDisplay.Click
Dim Password As String
Dim Passwordcounter As Integer
Password = "manager"
Passwordcounter = 0
If InputBox("Please enter your password") = Password And Passwordcounter <= 3 Then 'Create an Inputbox and enter password manager
DisplayStaff(ByVal Staff As Salestaff) 'Should pass values in parameter to function
Else : Passwordcounter += 1
If Passwordcounter >= 3 Then
MsgBox("You have had three attempts")
End
Else
MsgBox("Please try again")
InputBox("Please reenter your password")
End If
End If
End Sub