Visual Basic Survey and polling tools are often used in marketing or politics to
ID: 3807259 • Letter: V
Question
Visual Basic
Survey and polling tools are often used in marketing or politics to assess ratings for certain services or products. Polling tools can take many forms, some just use a simple dichotomous scale of Yes and No, or a more complex Likert Scale that consists of three or more choices. You can create Polling tool in Visual Basic easily by using the option buttons. In our program, the users are given five choices, Excellent, Very Good, Good, Satisfactory and Bad.The results are presented in frequency and percentage respectively.
In this example, we include a graphical display of the percentages of the five scores using the Line method. The syntax to draw the rectangular bar in a picture box is
PictureBox1.Size = New Size(90, 30)
where (x1,y1) is the coordinates of the upper left corner of the bar and
(x2,y2) is the coordinates of the lower right corner of the bar.
To show the bar length according to the percentage, we can use certain value to multiply the decimal value of each score and put it under x2.
Create at least 4 functions or procedures to accomplish this application.
Explanation / Answer
Visual Basic code to display survey using rectangular bar
Dim count, Excel_count, VG_count, G_count, Sat_count, Bad_count As Integer
Dim Excel_percent, VG_percent, G_percent, Sat_percent, Bad_percent As Single
Dim done As Boolean
Private Sub cmd_Vote_poll()
Picture1.Cls
If Option_Excel.Value = True Then
Excel_count = Excel_count + 1
Lbl_Excelcount = Excel_count
ElseIf Option_VG.Value = True Then
VG_count = VG_count + 1
Lbl_VGcount = VG_count
ElseIf Option_G.Value = True Then
G_count = G_count + 1
Lbl_GCount = G_Count
ElseIf Option_Sat.Value = True Then
Sat_count = Sat_count+ 1
Lbl_Satcount = Sat_count
ElseIf Option_Bad.Value = True Then
Bad_count = Bad_count + 1
Lbl_Badcount = Bad_count
End If
total = Excel_count + VG_count + G_count + Sat_count + Bad_count
Lbl_count= count
Excel_percent = Excel_count / count
VG_percent = VG_count / count
G_percent = G_count / count
Sat_percent = Sat_count / count
Bad_percent = Bad_count / count
Lbl_Excel.Caption = Format(Excel_percent, "Percent")
Lbl_VG.Caption = Format(VG_percent, "Percent")
Lbl_G.Caption = Format(G_percent, "Percent")
Lbl_Sat.Caption = Format(Sat_percent, "Percent")
Lbl_Bad.Caption = Format(Bad_percent, "Percent")
PictureBox1.Size = New Size(100, 750)-(3800 * Excel_percent, 950), vbRed, BF
PictureBox1.Size = New Size(100, 1450)-(3800 * VG_percent, 1650), vbMagenta, BF
PictureBox1.Size = New Size(100, 2150)-(3800 * G_percent, 2350), vbGreen, BF
PictureBox1.Size = New Size(100, 2850)-(3800 * Sat_percent, 3050), vbBlue, BF
PictureBox1.Size = New Size(100, 3550)-(3800 * Bad_percent, 3750), vbYellow, BF
End Sub
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.