|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
IO.File.AppendText errorboxes and appending it to a text file.... it was working, then I had to create various sub procedures to reflect limits set in place (class: A through C), (type: X, I, S), grade (4 through 6) Ive tried everything and it still wont work, anyone have any ideas? heres my code Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents lblLastName1 As System.Windows.Forms.Label Friend WithEvents lblLastName2 As System.Windows.Forms.Label Friend WithEvents lblFirstNameStudent1 As System.Windows.Forms.Label Friend WithEvents LblFirstNameStudent2 As System.Windows.Forms.Label Friend WithEvents txtLastNameStudent1 As System.Windows.Forms.TextBox Friend WithEvents txtFirstNameStudent1 As System.Windows.Forms.TextBox Friend WithEvents txtFirstNameStudent2 As System.Windows.Forms.TextBox Friend WithEvents txtLastNameStudent2 As System.Windows.Forms.TextBox Friend WithEvents txtProjectName As System.Windows.Forms.TextBox Friend WithEvents lblProjectName As System.Windows.Forms.Label Friend WithEvents lblGrade As System.Windows.Forms.Label Friend WithEvents lblClass As System.Windows.Forms.Label Friend WithEvents txtGrade As System.Windows.Forms.TextBox Friend WithEvents txtClass As System.Windows.Forms.TextBox Friend WithEvents lblType As System.Windows.Forms.Label Friend WithEvents txtType As System.Windows.Forms.TextBox Friend WithEvents btnAddtoRecord As System.Windows.Forms.Button Friend WithEvents dlgSaveFile As System.Windows.Forms.SaveFileDialog <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.lblLastName1 = New System.Windows.Forms.Label Me.lblLastName2 = New System.Windows.Forms.Label Me.lblFirstNameStudent1 = New System.Windows.Forms.Label Me.LblFirstNameStudent2 = New System.Windows.Forms.Label Me.txtLastNameStudent1 = New System.Windows.Forms.TextBox Me.txtFirstNameStudent1 = New System.Windows.Forms.TextBox Me.txtFirstNameStudent2 = New System.Windows.Forms.TextBox Me.txtLastNameStudent2 = New System.Windows.Forms.TextBox Me.txtProjectName = New System.Windows.Forms.TextBox Me.lblProjectName = New System.Windows.Forms.Label Me.lblGrade = New System.Windows.Forms.Label Me.txtGrade = New System.Windows.Forms.TextBox Me.lblClass = New System.Windows.Forms.Label Me.txtClass = New System.Windows.Forms.TextBox Me.lblType = New System.Windows.Forms.Label Me.txtType = New System.Windows.Forms.TextBox Me.btnAddtoRecord = New System.Windows.Forms.Button Me.dlgSaveFile = New System.Windows.Forms.SaveFileDialog Me.SuspendLayout() ' 'lblLastName1 ' Me.lblLastName1.Location = New System.Drawing.Point(8, 48) Me.lblLastName1.Name = "lblLastName1" Me.lblLastName1.Size = New System.Drawing.Size(128, 23) Me.lblLastName1.TabIndex = 0 Me.lblLastName1.Text = "Last Name of Student 1:" Me.lblLastName1.TextAlign = System.Drawing.ContentAlignment.TopRight ' 'lblLastName2 ' Me.lblLastName2.Location = New System.Drawing.Point(8, 112) Me.lblLastName2.Name = "lblLastName2" Me.lblLastName2.Size = New System.Drawing.Size(128, 23) Me.lblLastName2.TabIndex = 1 Me.lblLastName2.Text = "Last Name of Student 2:" Me.lblLastName2.TextAlign = System.Drawing.ContentAlignment.TopRight ' 'lblFirstNameStudent1 ' Me.lblFirstNameStudent1.Location = New System.Drawing.Point(8, 16) Me.lblFirstNameStudent1.Name = "lblFirstNameStudent1" Me.lblFirstNameStudent1.Size = New System.Drawing.Size(128, 23) Me.lblFirstNameStudent1.TabIndex = 2 Me.lblFirstNameStudent1.Text = "First Name of Student 1:" Me.lblFirstNameStudent1.TextAlign = System.Drawing.ContentAlignment.TopRight ' 'LblFirstNameStudent2 ' Me.LblFirstNameStudent2.Location = New System.Drawing.Point(8, 80) Me.LblFirstNameStudent2.Name = "LblFirstNameStudent2" Me.LblFirstNameStudent2.Size = New System.Drawing.Size(128, 23) Me.LblFirstNameStudent2.TabIndex = 3 Me.LblFirstNameStudent2.Text = "First Name of Student 2:" Me.LblFirstNameStudent2.TextAlign = System.Drawing.ContentAlignment.TopRight ' 'txtLastNameStudent1 ' Me.txtLastNameStudent1.Location = New System.Drawing.Point(144, 48) Me.txtLastNameStudent1.Name = "txtLastNameStudent1" Me.txtLastNameStudent1.Size = New System.Drawing.Size(160, 20) Me.txtLastNameStudent1.TabIndex = 4 Me.txtLastNameStudent1.Text = "" ' 'txtFirstNameStudent1 ' Me.txtFirstNameStudent1.Location = New System.Drawing.Point(144, 16) Me.txtFirstNameStudent1.Name = "txtFirstNameStudent1" Me.txtFirstNameStudent1.Size = New System.Drawing.Size(160, 20) Me.txtFirstNameStudent1.TabIndex = 5 Me.txtFirstNameStudent1.Text = "" ' 'txtFirstNameStudent2 ' Me.txtFirstNameStudent2.Location = New System.Drawing.Point(144, 80) Me.txtFirstNameStudent2.Name = "txtFirstNameStudent2" Me.txtFirstNameStudent2.Size = New System.Drawing.Size(160, 20) Me.txtFirstNameStudent2.TabIndex = 6 Me.txtFirstNameStudent2.Text = "" ' 'txtLastNameStudent2 ' Me.txtLastNameStudent2.Location = New System.Drawing.Point(144, 112) Me.txtLastNameStudent2.Name = "txtLastNameStudent2" Me.txtLastNameStudent2.Size = New System.Drawing.Size(160, 20) Me.txtLastNameStudent2.TabIndex = 7 Me.txtLastNameStudent2.Text = "" ' 'txtProjectName ' Me.txtProjectName.Location = New System.Drawing.Point(144, 144) Me.txtProjectName.Name = "txtProjectName" Me.txtProjectName.Size = New System.Drawing.Size(160, 20) Me.txtProjectName.TabIndex = 8 Me.txtProjectName.Text = "" ' 'lblProjectName ' Me.lblProjectName.Location = New System.Drawing.Point(8, 144) Me.lblProjectName.Name = "lblProjectName" Me.lblProjectName.Size = New System.Drawing.Size(128, 23) Me.lblProjectName.TabIndex = 9 Me.lblProjectName.Text = "Project Name:" Me.lblProjectName.TextAlign = System.Drawing.ContentAlignment.TopRight ' 'lblGrade ' Me.lblGrade.Location = New System.Drawing.Point(8, 176) Me.lblGrade.Name = "lblGrade" Me.lblGrade.Size = New System.Drawing.Size(128, 23) Me.lblGrade.TabIndex = 10 Me.lblGrade.Text = "Grade:" Me.lblGrade.TextAlign = System.Drawing.ContentAlignment.TopRight ' 'txtGrade ' Me.txtGrade.Location = New System.Drawing.Point(144, 176) Me.txtGrade.Name = "txtGrade" Me.txtGrade.Size = New System.Drawing.Size(160, 20) Me.txtGrade.TabIndex = 11 Me.txtGrade.Text = "" ' 'lblClass ' Me.lblClass.Location = New System.Drawing.Point(8, 208) Me.lblClass.Name = "lblClass" Me.lblClass.Size = New System.Drawing.Size(128, 23) Me.lblClass.TabIndex = 12 Me.lblClass.Text = "Class:" Me.lblClass.TextAlign = System.Drawing.ContentAlignment.TopRight ' 'txtClass ' Me.txtClass.Location = New System.Drawing.Point(144, 208) Me.txtClass.Name = "txtClass" Me.txtClass.Size = New System.Drawing.Size(160, 20) Me.txtClass.TabIndex = 13 Me.txtClass.Text = "" ' 'lblType ' Me.lblType.Location = New System.Drawing.Point(8, 240) Me.lblType.Name = "lblType" Me.lblType.Size = New System.Drawing.Size(128, 23) Me.lblType.TabIndex = 14 Me.lblType.Text = "Type:" Me.lblType.TextAlign = System.Drawing.ContentAlignment.TopRight ' 'txtType ' Me.txtType.Location = New System.Drawing.Point(144, 240) Me.txtType.Name = "txtType" Me.txtType.Size = New System.Drawing.Size(160, 20) Me.txtType.TabIndex = 15 Me.txtType.Text = "" ' 'btnAddtoRecord ' Me.btnAddtoRecord.Location = New System.Drawing.Point(160, 272) Me.btnAddtoRecord.Name = "btnAddtoRecord" Me.btnAddtoRecord.Size = New System.Drawing.Size(120, 24) Me.btnAddtoRecord.TabIndex = 16 Me.btnAddtoRecord.Text = "Add Entry To Record" ' 'dlgSaveFile ' Me.dlgSaveFile.Filter = "Text Files(*.txt)|" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(384, 318) Me.Controls.Add(Me.btnAddtoRecord) Me.Controls.Add(Me.txtType) Me.Controls.Add(Me.lblType) Me.Controls.Add(Me.txtClass) Me.Controls.Add(Me.lblClass) Me.Controls.Add(Me.txtGrade) Me.Controls.Add(Me.lblGrade) Me.Controls.Add(Me.lblProjectName) Me.Controls.Add(Me.txtProjectName) Me.Controls.Add(Me.txtLastNameStudent2) Me.Controls.Add(Me.txtFirstNameStudent2) Me.Controls.Add(Me.txtFirstNameStudent1) Me.Controls.Add(Me.txtLastNameStudent1) Me.Controls.Add(Me.LblFirstNameStudent2) Me.Controls.Add(Me.lblFirstNameStudent1) Me.Controls.Add(Me.lblLastName2) Me.Controls.Add(Me.lblLastName1) Me.Name = "Form1" Me.Text = "Science Fair Entries" Me.ResumeLayout(False) End Sub #End Region Private Sub btnAddtoRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddtoRecord.Click Dim x As Boolean CheckClass(x) If x Then CheckGrade(x) End If If x Then CheckType(x) End If Dim record As IO.StreamWriter = IO.File.AppendText(dlgSaveFile.FileName) record.WriteLine("") record.WriteLine("Names:" & " " & txtFirstNameStudent1.Text & " " & txtLastNameStudent1.Text & "," & " " & txtFirstNameStudent2.Text & " " & txtLastNameStudent2.Text) record.WriteLine("Type:" & " " & txtType.Text) record.WriteLine("Class:" & " " & txtGrade.Text & txtClass.Text) record.WriteLine("Project Title:" & " " & txtProjectName.Text) record.WriteLine(" ") record.WriteLine("======================================================") record.Close() txtFirstNameStudent1.Clear() txtLastNameStudent1.Clear() txtFirstNameStudent2.Clear() txtLastNameStudent2.Clear() txtClass.Clear() txtGrade.Clear() txtType.Clear() txtProjectName.Clear() End Sub Function CheckClass(ByRef classanalyze As Boolean) As Boolean Select Case txtClass.Text Case "A" classanalyze = True Case "B" classanalyze = True Case "C" classanalyze = True Case Else MsgBox("You have inputted an invalid Class. Please select a Class between A and C") classanalyze = False End Select Return classanalyze End Function Function CheckGrade(ByRef analyzegrade As Boolean) As Boolean Select Case txtGrade.Text Case "4" txtGrade.Text = "4" analyzegrade = True Case "5" txtGrade.Text = "5" analyzegrade = True Case "6" txtGrade.Text = "6" analyzegrade = True Case Else analyzegrade = False MsgBox("You have inputted an invalid Grade. Please select a Grade between 4 or 6") Return analyzegrade End Select End Function Function CheckType(ByRef typeanalyze As Boolean) As Boolean Dim type As String Select Case txtType.Text Case "I" txtType.Text = "Invention" typeanalyze = True Case "S" txtType.Text = "Study" typeanalyze = True Case "X" txtType.Text = "Experiment" typeanalyze = True Case Else typeanalyze = False MsgBox("You have inputted an invalid Project Type. Please enter I for an invention, X for an experiment, or S for a study") Return typeanalyze End Select End Function End Class Hi dc,
I have not tried your code, at first glance I can see at least a couple of Returns (Return typeanalyze, Return analyzegrade) which are within a CASE ELSE clause. Take them out of there .... dc15 ha scritto: Show quoteHide quote > I am trying to write an application, taking input from various text > boxes and appending it to a text file.... it was working, then I had to > create various sub procedures to reflect limits set in place (class: A > through C), (type: X, I, S), grade (4 through 6) > > Ive tried everything and it still wont work, anyone have any ideas? > > heres my code > > Public Class Form1 > Inherits System.Windows.Forms.Form > #Region " Windows Form Designer generated code " > > Public Sub New() > MyBase.New() > > 'This call is required by the Windows Form Designer. > InitializeComponent() > > 'Add any initialization after the InitializeComponent() call > > End Sub > > 'Form overrides dispose to clean up the component list. > Protected Overloads Overrides Sub Dispose(ByVal disposing As > Boolean) > If disposing Then > If Not (components Is Nothing) Then > components.Dispose() > End If > End If > MyBase.Dispose(disposing) > End Sub > > 'Required by the Windows Form Designer > Private components As System.ComponentModel.IContainer > > 'NOTE: The following procedure is required by the Windows Form > Designer > 'It can be modified using the Windows Form Designer. > 'Do not modify it using the code editor. > Friend WithEvents lblLastName1 As System.Windows.Forms.Label > Friend WithEvents lblLastName2 As System.Windows.Forms.Label > Friend WithEvents lblFirstNameStudent1 As > System.Windows.Forms.Label > Friend WithEvents LblFirstNameStudent2 As > System.Windows.Forms.Label > Friend WithEvents txtLastNameStudent1 As > System.Windows.Forms.TextBox > Friend WithEvents txtFirstNameStudent1 As > System.Windows.Forms.TextBox > Friend WithEvents txtFirstNameStudent2 As > System.Windows.Forms.TextBox > Friend WithEvents txtLastNameStudent2 As > System.Windows.Forms.TextBox > Friend WithEvents txtProjectName As System.Windows.Forms.TextBox > Friend WithEvents lblProjectName As System.Windows.Forms.Label > Friend WithEvents lblGrade As System.Windows.Forms.Label > Friend WithEvents lblClass As System.Windows.Forms.Label > Friend WithEvents txtGrade As System.Windows.Forms.TextBox > Friend WithEvents txtClass As System.Windows.Forms.TextBox > Friend WithEvents lblType As System.Windows.Forms.Label > Friend WithEvents txtType As System.Windows.Forms.TextBox > Friend WithEvents btnAddtoRecord As System.Windows.Forms.Button > Friend WithEvents dlgSaveFile As > System.Windows.Forms.SaveFileDialog > <System.Diagnostics.DebuggerStepThrough()> Private Sub > InitializeComponent() > Me.lblLastName1 = New System.Windows.Forms.Label > Me.lblLastName2 = New System.Windows.Forms.Label > Me.lblFirstNameStudent1 = New System.Windows.Forms.Label > Me.LblFirstNameStudent2 = New System.Windows.Forms.Label > Me.txtLastNameStudent1 = New System.Windows.Forms.TextBox > Me.txtFirstNameStudent1 = New System.Windows.Forms.TextBox > Me.txtFirstNameStudent2 = New System.Windows.Forms.TextBox > Me.txtLastNameStudent2 = New System.Windows.Forms.TextBox > Me.txtProjectName = New System.Windows.Forms.TextBox > Me.lblProjectName = New System.Windows.Forms.Label > Me.lblGrade = New System.Windows.Forms.Label > Me.txtGrade = New System.Windows.Forms.TextBox > Me.lblClass = New System.Windows.Forms.Label > Me.txtClass = New System.Windows.Forms.TextBox > Me.lblType = New System.Windows.Forms.Label > Me.txtType = New System.Windows.Forms.TextBox > Me.btnAddtoRecord = New System.Windows.Forms.Button > Me.dlgSaveFile = New System.Windows.Forms.SaveFileDialog > Me.SuspendLayout() > ' > 'lblLastName1 > ' > Me.lblLastName1.Location = New System.Drawing.Point(8, 48) > Me.lblLastName1.Name = "lblLastName1" > Me.lblLastName1.Size = New System.Drawing.Size(128, 23) > Me.lblLastName1.TabIndex = 0 > Me.lblLastName1.Text = "Last Name of Student 1:" > Me.lblLastName1.TextAlign = > System.Drawing.ContentAlignment.TopRight > ' > 'lblLastName2 > ' > Me.lblLastName2.Location = New System.Drawing.Point(8, 112) > Me.lblLastName2.Name = "lblLastName2" > Me.lblLastName2.Size = New System.Drawing.Size(128, 23) > Me.lblLastName2.TabIndex = 1 > Me.lblLastName2.Text = "Last Name of Student 2:" > Me.lblLastName2.TextAlign = > System.Drawing.ContentAlignment.TopRight > ' > 'lblFirstNameStudent1 > ' > Me.lblFirstNameStudent1.Location = New System.Drawing.Point(8, > 16) > Me.lblFirstNameStudent1.Name = "lblFirstNameStudent1" > Me.lblFirstNameStudent1.Size = New System.Drawing.Size(128, 23) > Me.lblFirstNameStudent1.TabIndex = 2 > Me.lblFirstNameStudent1.Text = "First Name of Student 1:" > Me.lblFirstNameStudent1.TextAlign = > System.Drawing.ContentAlignment.TopRight > ' > 'LblFirstNameStudent2 > ' > Me.LblFirstNameStudent2.Location = New System.Drawing.Point(8, > 80) > Me.LblFirstNameStudent2.Name = "LblFirstNameStudent2" > Me.LblFirstNameStudent2.Size = New System.Drawing.Size(128, 23) > Me.LblFirstNameStudent2.TabIndex = 3 > Me.LblFirstNameStudent2.Text = "First Name of Student 2:" > Me.LblFirstNameStudent2.TextAlign = > System.Drawing.ContentAlignment.TopRight > ' > 'txtLastNameStudent1 > ' > Me.txtLastNameStudent1.Location = New System.Drawing.Point(144, > 48) > Me.txtLastNameStudent1.Name = "txtLastNameStudent1" > Me.txtLastNameStudent1.Size = New System.Drawing.Size(160, 20) > Me.txtLastNameStudent1.TabIndex = 4 > Me.txtLastNameStudent1.Text = "" > ' > 'txtFirstNameStudent1 > ' > Me.txtFirstNameStudent1.Location = New > System.Drawing.Point(144, 16) > Me.txtFirstNameStudent1.Name = "txtFirstNameStudent1" > Me.txtFirstNameStudent1.Size = New System.Drawing.Size(160, 20) > Me.txtFirstNameStudent1.TabIndex = 5 > Me.txtFirstNameStudent1.Text = "" > ' > 'txtFirstNameStudent2 > ' > Me.txtFirstNameStudent2.Location = New > System.Drawing.Point(144, 80) > Me.txtFirstNameStudent2.Name = "txtFirstNameStudent2" > Me.txtFirstNameStudent2.Size = New System.Drawing.Size(160, 20) > Me.txtFirstNameStudent2.TabIndex = 6 > Me.txtFirstNameStudent2.Text = "" > ' > 'txtLastNameStudent2 > ' > Me.txtLastNameStudent2.Location = New System.Drawing.Point(144, > 112) > Me.txtLastNameStudent2.Name = "txtLastNameStudent2" > Me.txtLastNameStudent2.Size = New System.Drawing.Size(160, 20) > Me.txtLastNameStudent2.TabIndex = 7 > Me.txtLastNameStudent2.Text = "" > ' > 'txtProjectName > ' > Me.txtProjectName.Location = New System.Drawing.Point(144, 144) > Me.txtProjectName.Name = "txtProjectName" > Me.txtProjectName.Size = New System.Drawing.Size(160, 20) > Me.txtProjectName.TabIndex = 8 > Me.txtProjectName.Text = "" > ' > 'lblProjectName > ' > Me.lblProjectName.Location = New System.Drawing.Point(8, 144) > Me.lblProjectName.Name = "lblProjectName" > Me.lblProjectName.Size = New System.Drawing.Size(128, 23) > Me.lblProjectName.TabIndex = 9 > Me.lblProjectName.Text = "Project Name:" > Me.lblProjectName.TextAlign = > System.Drawing.ContentAlignment.TopRight > ' > 'lblGrade > ' > Me.lblGrade.Location = New System.Drawing.Point(8, 176) > Me.lblGrade.Name = "lblGrade" > Me.lblGrade.Size = New System.Drawing.Size(128, 23) > Me.lblGrade.TabIndex = 10 > Me.lblGrade.Text = "Grade:" > Me.lblGrade.TextAlign = > System.Drawing.ContentAlignment.TopRight > ' > 'txtGrade > ' > Me.txtGrade.Location = New System.Drawing.Point(144, 176) > Me.txtGrade.Name = "txtGrade" > Me.txtGrade.Size = New System.Drawing.Size(160, 20) > Me.txtGrade.TabIndex = 11 > Me.txtGrade.Text = "" > ' > 'lblClass > ' > Me.lblClass.Location = New System.Drawing.Point(8, 208) > Me.lblClass.Name = "lblClass" > Me.lblClass.Size = New System.Drawing.Size(128, 23) > Me.lblClass.TabIndex = 12 > Me.lblClass.Text = "Class:" > Me.lblClass.TextAlign = > System.Drawing.ContentAlignment.TopRight > ' > 'txtClass > ' > Me.txtClass.Location = New System.Drawing.Point(144, 208) > Me.txtClass.Name = "txtClass" > Me.txtClass.Size = New System.Drawing.Size(160, 20) > Me.txtClass.TabIndex = 13 > Me.txtClass.Text = "" > ' > 'lblType > ' > Me.lblType.Location = New System.Drawing.Point(8, 240) > Me.lblType.Name = "lblType" > Me.lblType.Size = New System.Drawing.Size(128, 23) > Me.lblType.TabIndex = 14 > Me.lblType.Text = "Type:" > Me.lblType.TextAlign = System.Drawing.ContentAlignment.TopRight > ' > 'txtType > ' > Me.txtType.Location = New System.Drawing.Point(144, 240) > Me.txtType.Name = "txtType" > Me.txtType.Size = New System.Drawing.Size(160, 20) > Me.txtType.TabIndex = 15 > Me.txtType.Text = "" > ' > 'btnAddtoRecord > ' > Me.btnAddtoRecord.Location = New System.Drawing.Point(160, 272) > Me.btnAddtoRecord.Name = "btnAddtoRecord" > Me.btnAddtoRecord.Size = New System.Drawing.Size(120, 24) > Me.btnAddtoRecord.TabIndex = 16 > Me.btnAddtoRecord.Text = "Add Entry To Record" > ' > 'dlgSaveFile > ' > Me.dlgSaveFile.Filter = "Text Files(*.txt)|" > ' > 'Form1 > ' > Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) > Me.ClientSize = New System.Drawing.Size(384, 318) > Me.Controls.Add(Me.btnAddtoRecord) > Me.Controls.Add(Me.txtType) > Me.Controls.Add(Me.lblType) > Me.Controls.Add(Me.txtClass) > Me.Controls.Add(Me.lblClass) > Me.Controls.Add(Me.txtGrade) > Me.Controls.Add(Me.lblGrade) > Me.Controls.Add(Me.lblProjectName) > Me.Controls.Add(Me.txtProjectName) > Me.Controls.Add(Me.txtLastNameStudent2) > Me.Controls.Add(Me.txtFirstNameStudent2) > Me.Controls.Add(Me.txtFirstNameStudent1) > Me.Controls.Add(Me.txtLastNameStudent1) > Me.Controls.Add(Me.LblFirstNameStudent2) > Me.Controls.Add(Me.lblFirstNameStudent1) > Me.Controls.Add(Me.lblLastName2) > Me.Controls.Add(Me.lblLastName1) > Me.Name = "Form1" > Me.Text = "Science Fair Entries" > Me.ResumeLayout(False) > > End Sub > > #End Region > > Private Sub btnAddtoRecord_Click(ByVal sender As System.Object, > ByVal e As System.EventArgs) Handles btnAddtoRecord.Click > Dim x As Boolean > CheckClass(x) > If x Then > CheckGrade(x) > End If > If x Then > CheckType(x) > End If > Dim record As IO.StreamWriter = > IO.File.AppendText(dlgSaveFile.FileName) > record.WriteLine("") > record.WriteLine("Names:" & " " & txtFirstNameStudent1.Text & " > " & txtLastNameStudent1.Text & "," & " " & txtFirstNameStudent2.Text & > " " & txtLastNameStudent2.Text) > record.WriteLine("Type:" & " " & txtType.Text) > record.WriteLine("Class:" & " " & txtGrade.Text & > txtClass.Text) > record.WriteLine("Project Title:" & " " & txtProjectName.Text) > record.WriteLine(" ") > > record.WriteLine("======================================================") > record.Close() > txtFirstNameStudent1.Clear() > txtLastNameStudent1.Clear() > txtFirstNameStudent2.Clear() > txtLastNameStudent2.Clear() > txtClass.Clear() > txtGrade.Clear() > txtType.Clear() > txtProjectName.Clear() > End Sub > Function CheckClass(ByRef classanalyze As Boolean) As Boolean > Select Case txtClass.Text > Case "A" > classanalyze = True > Case "B" > classanalyze = True > Case "C" > classanalyze = True > Case Else > MsgBox("You have inputted an invalid Class. Please > select a Class between A and C") > classanalyze = False > End Select > Return classanalyze > End Function > Function CheckGrade(ByRef analyzegrade As Boolean) As Boolean > Select Case txtGrade.Text > Case "4" > txtGrade.Text = "4" > analyzegrade = True > > Case "5" > txtGrade.Text = "5" > analyzegrade = True > Case "6" > txtGrade.Text = "6" > analyzegrade = True > Case Else > analyzegrade = False > MsgBox("You have inputted an invalid Grade. Please > select a Grade between 4 or 6") > Return analyzegrade > End Select > End Function > Function CheckType(ByRef typeanalyze As Boolean) As Boolean > Dim type As String > Select Case txtType.Text > Case "I" > txtType.Text = "Invention" > typeanalyze = True > Case "S" > txtType.Text = "Study" > typeanalyze = True > Case "X" > txtType.Text = "Experiment" > typeanalyze = True > Case Else > typeanalyze = False > MsgBox("You have inputted an invalid Project Type. > Please enter I for an invention, X for an experiment, or S for a > study") > Return typeanalyze > End Select > End Function > > End Class Define "won't work". Are you getting an error? Step through the code in the
debugger to see what is going on Jeff Show quoteHide quote "dc15" <deese***@gmail.com> wrote in message news:1144943616.343718.271900@i40g2000cwc.googlegroups.com... >I am trying to write an application, taking input from various text > boxes and appending it to a text file.... it was working, then I had to > create various sub procedures to reflect limits set in place (class: A > through C), (type: X, I, S), grade (4 through 6) > > Ive tried everything and it still wont work, anyone have any ideas? > > heres my code > > Public Class Form1 > Inherits System.Windows.Forms.Form > #Region " Windows Form Designer generated code " > > Public Sub New() > MyBase.New() > > 'This call is required by the Windows Form Designer. > InitializeComponent() > > 'Add any initialization after the InitializeComponent() call > > End Sub > > 'Form overrides dispose to clean up the component list. > Protected Overloads Overrides Sub Dispose(ByVal disposing As > Boolean) > If disposing Then > If Not (components Is Nothing) Then > components.Dispose() > End If > End If > MyBase.Dispose(disposing) > End Sub > > 'Required by the Windows Form Designer > Private components As System.ComponentModel.IContainer > > 'NOTE: The following procedure is required by the Windows Form > Designer > 'It can be modified using the Windows Form Designer. > 'Do not modify it using the code editor. > Friend WithEvents lblLastName1 As System.Windows.Forms.Label > Friend WithEvents lblLastName2 As System.Windows.Forms.Label > Friend WithEvents lblFirstNameStudent1 As > System.Windows.Forms.Label > Friend WithEvents LblFirstNameStudent2 As > System.Windows.Forms.Label > Friend WithEvents txtLastNameStudent1 As > System.Windows.Forms.TextBox > Friend WithEvents txtFirstNameStudent1 As > System.Windows.Forms.TextBox > Friend WithEvents txtFirstNameStudent2 As > System.Windows.Forms.TextBox > Friend WithEvents txtLastNameStudent2 As > System.Windows.Forms.TextBox > Friend WithEvents txtProjectName As System.Windows.Forms.TextBox > Friend WithEvents lblProjectName As System.Windows.Forms.Label > Friend WithEvents lblGrade As System.Windows.Forms.Label > Friend WithEvents lblClass As System.Windows.Forms.Label > Friend WithEvents txtGrade As System.Windows.Forms.TextBox > Friend WithEvents txtClass As System.Windows.Forms.TextBox > Friend WithEvents lblType As System.Windows.Forms.Label > Friend WithEvents txtType As System.Windows.Forms.TextBox > Friend WithEvents btnAddtoRecord As System.Windows.Forms.Button > Friend WithEvents dlgSaveFile As > System.Windows.Forms.SaveFileDialog > <System.Diagnostics.DebuggerStepThrough()> Private Sub > InitializeComponent() > Me.lblLastName1 = New System.Windows.Forms.Label > Me.lblLastName2 = New System.Windows.Forms.Label > Me.lblFirstNameStudent1 = New System.Windows.Forms.Label > Me.LblFirstNameStudent2 = New System.Windows.Forms.Label > Me.txtLastNameStudent1 = New System.Windows.Forms.TextBox > Me.txtFirstNameStudent1 = New System.Windows.Forms.TextBox > Me.txtFirstNameStudent2 = New System.Windows.Forms.TextBox > Me.txtLastNameStudent2 = New System.Windows.Forms.TextBox > Me.txtProjectName = New System.Windows.Forms.TextBox > Me.lblProjectName = New System.Windows.Forms.Label > Me.lblGrade = New System.Windows.Forms.Label > Me.txtGrade = New System.Windows.Forms.TextBox > Me.lblClass = New System.Windows.Forms.Label > Me.txtClass = New System.Windows.Forms.TextBox > Me.lblType = New System.Windows.Forms.Label > Me.txtType = New System.Windows.Forms.TextBox > Me.btnAddtoRecord = New System.Windows.Forms.Button > Me.dlgSaveFile = New System.Windows.Forms.SaveFileDialog > Me.SuspendLayout() > ' > 'lblLastName1 > ' > Me.lblLastName1.Location = New System.Drawing.Point(8, 48) > Me.lblLastName1.Name = "lblLastName1" > Me.lblLastName1.Size = New System.Drawing.Size(128, 23) > Me.lblLastName1.TabIndex = 0 > Me.lblLastName1.Text = "Last Name of Student 1:" > Me.lblLastName1.TextAlign = > System.Drawing.ContentAlignment.TopRight > ' > 'lblLastName2 > ' > Me.lblLastName2.Location = New System.Drawing.Point(8, 112) > Me.lblLastName2.Name = "lblLastName2" > Me.lblLastName2.Size = New System.Drawing.Size(128, 23) > Me.lblLastName2.TabIndex = 1 > Me.lblLastName2.Text = "Last Name of Student 2:" > Me.lblLastName2.TextAlign = > System.Drawing.ContentAlignment.TopRight > ' > 'lblFirstNameStudent1 > ' > Me.lblFirstNameStudent1.Location = New System.Drawing.Point(8, > 16) > Me.lblFirstNameStudent1.Name = "lblFirstNameStudent1" > Me.lblFirstNameStudent1.Size = New System.Drawing.Size(128, 23) > Me.lblFirstNameStudent1.TabIndex = 2 > Me.lblFirstNameStudent1.Text = "First Name of Student 1:" > Me.lblFirstNameStudent1.TextAlign = > System.Drawing.ContentAlignment.TopRight > ' > 'LblFirstNameStudent2 > ' > Me.LblFirstNameStudent2.Location = New System.Drawing.Point(8, > 80) > Me.LblFirstNameStudent2.Name = "LblFirstNameStudent2" > Me.LblFirstNameStudent2.Size = New System.Drawing.Size(128, 23) > Me.LblFirstNameStudent2.TabIndex = 3 > Me.LblFirstNameStudent2.Text = "First Name of Student 2:" > Me.LblFirstNameStudent2.TextAlign = > System.Drawing.ContentAlignment.TopRight > ' > 'txtLastNameStudent1 > ' > Me.txtLastNameStudent1.Location = New System.Drawing.Point(144, > 48) > Me.txtLastNameStudent1.Name = "txtLastNameStudent1" > Me.txtLastNameStudent1.Size = New System.Drawing.Size(160, 20) > Me.txtLastNameStudent1.TabIndex = 4 > Me.txtLastNameStudent1.Text = "" > ' > 'txtFirstNameStudent1 > ' > Me.txtFirstNameStudent1.Location = New > System.Drawing.Point(144, 16) > Me.txtFirstNameStudent1.Name = "txtFirstNameStudent1" > Me.txtFirstNameStudent1.Size = New System.Drawing.Size(160, 20) > Me.txtFirstNameStudent1.TabIndex = 5 > Me.txtFirstNameStudent1.Text = "" > ' > 'txtFirstNameStudent2 > ' > Me.txtFirstNameStudent2.Location = New > System.Drawing.Point(144, 80) > Me.txtFirstNameStudent2.Name = "txtFirstNameStudent2" > Me.txtFirstNameStudent2.Size = New System.Drawing.Size(160, 20) > Me.txtFirstNameStudent2.TabIndex = 6 > Me.txtFirstNameStudent2.Text = "" > ' > 'txtLastNameStudent2 > ' > Me.txtLastNameStudent2.Location = New System.Drawing.Point(144, > 112) > Me.txtLastNameStudent2.Name = "txtLastNameStudent2" > Me.txtLastNameStudent2.Size = New System.Drawing.Size(160, 20) > Me.txtLastNameStudent2.TabIndex = 7 > Me.txtLastNameStudent2.Text = "" > ' > 'txtProjectName > ' > Me.txtProjectName.Location = New System.Drawing.Point(144, 144) > Me.txtProjectName.Name = "txtProjectName" > Me.txtProjectName.Size = New System.Drawing.Size(160, 20) > Me.txtProjectName.TabIndex = 8 > Me.txtProjectName.Text = "" > ' > 'lblProjectName > ' > Me.lblProjectName.Location = New System.Drawing.Point(8, 144) > Me.lblProjectName.Name = "lblProjectName" > Me.lblProjectName.Size = New System.Drawing.Size(128, 23) > Me.lblProjectName.TabIndex = 9 > Me.lblProjectName.Text = "Project Name:" > Me.lblProjectName.TextAlign = > System.Drawing.ContentAlignment.TopRight > ' > 'lblGrade > ' > Me.lblGrade.Location = New System.Drawing.Point(8, 176) > Me.lblGrade.Name = "lblGrade" > Me.lblGrade.Size = New System.Drawing.Size(128, 23) > Me.lblGrade.TabIndex = 10 > Me.lblGrade.Text = "Grade:" > Me.lblGrade.TextAlign = > System.Drawing.ContentAlignment.TopRight > ' > 'txtGrade > ' > Me.txtGrade.Location = New System.Drawing.Point(144, 176) > Me.txtGrade.Name = "txtGrade" > Me.txtGrade.Size = New System.Drawing.Size(160, 20) > Me.txtGrade.TabIndex = 11 > Me.txtGrade.Text = "" > ' > 'lblClass > ' > Me.lblClass.Location = New System.Drawing.Point(8, 208) > Me.lblClass.Name = "lblClass" > Me.lblClass.Size = New System.Drawing.Size(128, 23) > Me.lblClass.TabIndex = 12 > Me.lblClass.Text = "Class:" > Me.lblClass.TextAlign = > System.Drawing.ContentAlignment.TopRight > ' > 'txtClass > ' > Me.txtClass.Location = New System.Drawing.Point(144, 208) > Me.txtClass.Name = "txtClass" > Me.txtClass.Size = New System.Drawing.Size(160, 20) > Me.txtClass.TabIndex = 13 > Me.txtClass.Text = "" > ' > 'lblType > ' > Me.lblType.Location = New System.Drawing.Point(8, 240) > Me.lblType.Name = "lblType" > Me.lblType.Size = New System.Drawing.Size(128, 23) > Me.lblType.TabIndex = 14 > Me.lblType.Text = "Type:" > Me.lblType.TextAlign = System.Drawing.ContentAlignment.TopRight > ' > 'txtType > ' > Me.txtType.Location = New System.Drawing.Point(144, 240) > Me.txtType.Name = "txtType" > Me.txtType.Size = New System.Drawing.Size(160, 20) > Me.txtType.TabIndex = 15 > Me.txtType.Text = "" > ' > 'btnAddtoRecord > ' > Me.btnAddtoRecord.Location = New System.Drawing.Point(160, 272) > Me.btnAddtoRecord.Name = "btnAddtoRecord" > Me.btnAddtoRecord.Size = New System.Drawing.Size(120, 24) > Me.btnAddtoRecord.TabIndex = 16 > Me.btnAddtoRecord.Text = "Add Entry To Record" > ' > 'dlgSaveFile > ' > Me.dlgSaveFile.Filter = "Text Files(*.txt)|" > ' > 'Form1 > ' > Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) > Me.ClientSize = New System.Drawing.Size(384, 318) > Me.Controls.Add(Me.btnAddtoRecord) > Me.Controls.Add(Me.txtType) > Me.Controls.Add(Me.lblType) > Me.Controls.Add(Me.txtClass) > Me.Controls.Add(Me.lblClass) > Me.Controls.Add(Me.txtGrade) > Me.Controls.Add(Me.lblGrade) > Me.Controls.Add(Me.lblProjectName) > Me.Controls.Add(Me.txtProjectName) > Me.Controls.Add(Me.txtLastNameStudent2) > Me.Controls.Add(Me.txtFirstNameStudent2) > Me.Controls.Add(Me.txtFirstNameStudent1) > Me.Controls.Add(Me.txtLastNameStudent1) > Me.Controls.Add(Me.LblFirstNameStudent2) > Me.Controls.Add(Me.lblFirstNameStudent1) > Me.Controls.Add(Me.lblLastName2) > Me.Controls.Add(Me.lblLastName1) > Me.Name = "Form1" > Me.Text = "Science Fair Entries" > Me.ResumeLayout(False) > > End Sub > > #End Region > > Private Sub btnAddtoRecord_Click(ByVal sender As System.Object, > ByVal e As System.EventArgs) Handles btnAddtoRecord.Click > Dim x As Boolean > CheckClass(x) > If x Then > CheckGrade(x) > End If > If x Then > CheckType(x) > End If > Dim record As IO.StreamWriter = > IO.File.AppendText(dlgSaveFile.FileName) > record.WriteLine("") > record.WriteLine("Names:" & " " & txtFirstNameStudent1.Text & " > " & txtLastNameStudent1.Text & "," & " " & txtFirstNameStudent2.Text & > " " & txtLastNameStudent2.Text) > record.WriteLine("Type:" & " " & txtType.Text) > record.WriteLine("Class:" & " " & txtGrade.Text & > txtClass.Text) > record.WriteLine("Project Title:" & " " & txtProjectName.Text) > record.WriteLine(" ") > > record.WriteLine("======================================================") > record.Close() > txtFirstNameStudent1.Clear() > txtLastNameStudent1.Clear() > txtFirstNameStudent2.Clear() > txtLastNameStudent2.Clear() > txtClass.Clear() > txtGrade.Clear() > txtType.Clear() > txtProjectName.Clear() > End Sub > Function CheckClass(ByRef classanalyze As Boolean) As Boolean > Select Case txtClass.Text > Case "A" > classanalyze = True > Case "B" > classanalyze = True > Case "C" > classanalyze = True > Case Else > MsgBox("You have inputted an invalid Class. Please > select a Class between A and C") > classanalyze = False > End Select > Return classanalyze > End Function > Function CheckGrade(ByRef analyzegrade As Boolean) As Boolean > Select Case txtGrade.Text > Case "4" > txtGrade.Text = "4" > analyzegrade = True > > Case "5" > txtGrade.Text = "5" > analyzegrade = True > Case "6" > txtGrade.Text = "6" > analyzegrade = True > Case Else > analyzegrade = False > MsgBox("You have inputted an invalid Grade. Please > select a Grade between 4 or 6") > Return analyzegrade > End Select > End Function > Function CheckType(ByRef typeanalyze As Boolean) As Boolean > Dim type As String > Select Case txtType.Text > Case "I" > txtType.Text = "Invention" > typeanalyze = True > Case "S" > txtType.Text = "Study" > typeanalyze = True > Case "X" > txtType.Text = "Experiment" > typeanalyze = True > Case Else > typeanalyze = False > MsgBox("You have inputted an invalid Project Type. > Please enter I for an invention, X for an experiment, or S for a > study") > Return typeanalyze > End Select > End Function > > End Class >
Accessing a camrea
& char in XML document Send email best use of vb.net and multithreading Crystal "PrintToPrinter" will not print to Zebra Label Printer... HELP! Duplicate controls on tab pages vb.net Automation Issues - COM Interop "Cross-thread operation not valid" without threading!! ComboBox in Bound DataGrid (VB 2003) Deleting INI file entry |
|||||||||||||||||||||||