Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27348

VS 2008 NEed help with my project

$
0
0
The problem is i need my printout in a tableview I dont have a idea how to do this, and another thing is I need to add a average label to my printout that will workout the average of each question.

ThAnks Mark

Code:

Public Class Survey
Dim survey(10, 5) As Integer
Private Sub btn_Exit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Exit.Click
End
End Sub

Private Sub btn_Submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Submit.Click
'Question 1
If Radio_11.Checked = True Then
survey(0, 0) = survey(0, 0) + 1
ElseIf Radio_12.Checked = True Then
survey(0, 1) = survey(0, 1) + 1
ElseIf Radio_13.Checked = True Then
survey(0, 2) = survey(0, 2) + 1
ElseIf Radio_14.Checked = True Then
survey(0, 3) = survey(0, 3) + 1
ElseIf Radio_15.Checked = True Then
survey(0, 4) = survey(0, 4) + 1
End If

'Question 2
If Radio_21.Checked = True Then
survey(1, 0) = survey(1, 0) + 1
ElseIf Radio_22.Checked = True Then
survey(1, 1) = survey(1, 1) + 1
ElseIf Radio_23.Checked = True Then
survey(1, 2) = survey(1, 2) + 1
ElseIf Radio_24.Checked = True Then
survey(1, 3) = survey(1, 3) + 1
ElseIf Radio_25.Checked = True Then
survey(1, 4) = survey(1, 4) + 1
End If

'Question 3
If Radio_31.Checked = True Then
survey(2, 0) = survey(2, 0) + 1
ElseIf Radio_32.Checked = True Then
survey(2, 1) = survey(2, 1) + 1
ElseIf Radio_33.Checked = True Then
survey(2, 2) = survey(2, 2) + 1
ElseIf Radio_34.Checked = True Then
survey(2, 3) = survey(2, 3) + 1
ElseIf Radio_35.Checked = True Then
survey(2, 4) = survey(2, 4) + 1
End If

'Question 4
If Radio_41.Checked = True Then
survey(3, 0) = survey(3, 0) + 1
ElseIf Radio_42.Checked = True Then
survey(3, 1) = survey(3, 1) + 1
ElseIf Radio_43.Checked = True Then
survey(3, 2) = survey(3, 2) + 1
ElseIf Radio_44.Checked = True Then
survey(3, 3) = survey(3, 3) + 1
ElseIf Radio_45.Checked = True Then
survey(3, 4) = survey(3, 4) + 1
End If

'Question 5
If Radio_51.Checked = True Then
survey(4, 0) = survey(4, 0) + 1
ElseIf Radio_52.Checked = True Then
survey(4, 1) = survey(4, 1) + 1
ElseIf Radio_53.Checked = True Then
survey(4, 2) = survey(4, 2) + 1
ElseIf Radio_54.Checked = True Then
survey(4, 3) = survey(4, 3) + 1
ElseIf Radio_55.Checked = True Then
survey(4, 4) = survey(4, 4) + 1
End If

'Question 6
If Radio_61.Checked = True Then
survey(5, 0) = survey(5, 0) + 1
ElseIf Radio_62.Checked = True Then
survey(5, 1) = survey(5, 1) + 1
ElseIf Radio_63.Checked = True Then
survey(5, 2) = survey(5, 2) + 1
ElseIf Radio_64.Checked = True Then
survey(5, 3) = survey(5, 3) + 1
ElseIf Radio_65.Checked = True Then
survey(5, 4) = survey(5, 4) + 1
End If

'Question 7
If Radio_71.Checked = True Then
survey(6, 0) = survey(6, 0) + 1
ElseIf Radio_72.Checked = True Then
survey(6, 1) = survey(6, 1) + 1
ElseIf Radio_73.Checked = True Then
survey(6, 2) = survey(6, 2) + 1
ElseIf Radio_74.Checked = True Then
survey(6, 3) = survey(6, 3) + 1
ElseIf Radio_75.Checked = True Then
survey(6, 4) = survey(6, 4) + 1
End If

'Question 8
If Radio_81.Checked = True Then
survey(7, 0) = survey(7, 0) + 1
ElseIf Radio_82.Checked = True Then
survey(7, 1) = survey(7, 1) + 1
ElseIf Radio_83.Checked = True Then
survey(7, 2) = survey(7, 2) + 1
ElseIf Radio_84.Checked = True Then
survey(7, 3) = survey(7, 3) + 1
ElseIf Radio_85.Checked = True Then
survey(7, 4) = survey(7, 4) + 1
End If

'Question 9
If Radio_91.Checked = True Then
survey(8, 0) = survey(8, 0) + 1
ElseIf Radio_92.Checked = True Then
survey(8, 1) = survey(8, 1) + 1
ElseIf Radio_93.Checked = True Then
survey(8, 2) = survey(8, 2) + 1
ElseIf Radio_94.Checked = True Then
survey(8, 3) = survey(8, 3) + 1
ElseIf Radio_95.Checked = True Then
survey(8, 4) = survey(8, 4) + 1
End If

'Question 10
If Radio_101.Checked = True Then
survey(9, 0) = survey(9, 0) + 1
ElseIf Radio_102.Checked = True Then
survey(9, 1) = survey(9, 1) + 1
ElseIf Radio_103.Checked = True Then
survey(9, 2) = survey(9, 2) + 1
ElseIf Radio_104.Checked = True Then
survey(9, 3) = survey(9, 3) + 1
ElseIf Radio_105.Checked = True Then
survey(9, 4) = survey(9, 4) + 1
End If
MsgBox("Submitted")
End Sub

Private Sub btn_Clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Clear.Click
'Question 1
Radio_11.Checked = False
Radio_12.Checked = False
Radio_13.Checked = False
Radio_14.Checked = False
Radio_15.Checked = False


'Question 2
Radio_21.Checked = False
Radio_22.Checked = False
Radio_23.Checked = False
Radio_24.Checked = False
Radio_25.Checked = False


'Question 3
Radio_31.Checked = False
Radio_32.Checked = False
Radio_33.Checked = False
Radio_34.Checked = False
Radio_35.Checked = False


'Question 4
Radio_41.Checked = False
Radio_42.Checked = False
Radio_43.Checked = False
Radio_44.Checked = False
Radio_45.Checked = False


'Question 5
Radio_51.Checked = False
Radio_52.Checked = False
Radio_53.Checked = False
Radio_54.Checked = False
Radio_55.Checked = False


'Question 6
Radio_61.Checked = False
Radio_62.Checked = False
Radio_63.Checked = False
Radio_64.Checked = False
Radio_65.Checked = False


'Question 7
Radio_71.Checked = False
Radio_72.Checked = False
Radio_73.Checked = False
Radio_74.Checked = False
Radio_75.Checked = False


'Question 8
Radio_81.Checked = False
Radio_82.Checked = False
Radio_83.Checked = False
Radio_84.Checked = False
Radio_85.Checked = False


'Question 9
Radio_91.Checked = False
Radio_92.Checked = False
Radio_93.Checked = False
Radio_94.Checked = False
Radio_95.Checked = False


'Question 10
Radio_101.Checked = False
Radio_102.Checked = False
Radio_103.Checked = False
Radio_104.Checked = False
Radio_105.Checked = False

End Sub

Private Sub btn_PrintPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_PrintPreview.Click
Try
PrintPreviewDialog1.Document = PrintDocument1
Catch es As Exception
MessageBox.Show(es.Message)
End Try
PrintPreviewDialog1.ShowDialog()
End Sub

Private Sub Survey_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i, j As Integer
For i = 0 To 9
For j = 0 To 4
survey(i, j) = 0
Next
Next
End Sub

Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
'Begin the print process to print all items.
Dim printLineString As String = ""
Dim printFont As New Font("arial", 12)
Dim headingFont As New Font("arial", 15)
Dim lineHeightSingle As Single = printFont.GetHeight + 2
Dim horizontalPrintLocationSingle As Single = e.MarginBounds.Left
Dim verticalprintlocationSingle As Single = e.MarginBounds.Top

Dim linesPerPage As Single = 0
Dim yPosition As Single = 0
Dim count As Integer = 0
Dim leftMargin As Single = e.MarginBounds.Left
Dim topMargin As Single = e.MarginBounds.Top
Dim line As String = Nothing
Dim myBrush As New SolidBrush(Color.Black)
' Work out the number of lines per page, using the MarginBounds.
linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics)

printLineString = "Question|Always|Usually|Sometimes|Seldom|Never" + vbLf
Dim i As Integer
For i = 0 To 9
printLineString = printLineString + (i + 1).ToString + " | " + survey(i, 0).ToString + vbTab + " | " + survey(i, 1).ToString + vbTab + " | " + survey(i, 2).ToString + vbTab + " | " + survey(i, 3).ToString + vbTab + " | " + survey(i, 4).ToString + vbLf
Next
'MsgBox(printLineString)
'name and a heading at the top of the report
printLineString = "Programmed by: me Project: Survey Report" & vbCrLf & printLineString
'send the line to the graphics page object
e.Graphics.DrawString(printLineString, printFont, Brushes.Black, horizontalPrintLocationSingle, verticalprintlocationSingle)

End Sub

Private Sub btn_Print_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Print.Click
PrintDialog1.Document = PrintDocument1

If PrintDialog1.ShowDialog() = 1 Then
PrintDocument1.Print()
End If
End Sub

Private Sub Radio_11_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Radio_11.CheckedChanged

End Sub
End Class

Viewing all articles
Browse latest Browse all 27348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>