Ok, my friend is almost failing his VB class. He sent me the code but all I have in the VB integrated into MSWord and everything is red. He has trouble with one of the loops and with the multiplication operator.Ok, here's the code:Option Strict OnOption Explicit On Public Class uiClassPlacementInherits 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() callEnd Sub'Form overrides dispose to clean up the component list.Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)If disposing ThenIf Not (components Is Nothing) Thencomponents.Dispose()End IfEnd IfMyBase.Dispose(disposing)End Sub'Required by the Windows Form DesignerPrivate 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 uiPositiveIntegerLabel As System.Windows.Forms.LabelFriend WithEvents uiSumLabel As System.Windows.Forms.LabelFriend WithEvents uiProductLabel As System.Windows.Forms.LabelFriend WithEvents uiOddEvenLabel As System.Windows.Forms.LabelFriend WithEvents uiIntegerAnswerTextBox As System.Windows.Forms.TextBoxFriend WithEvents uiGoButton As System.Windows.Forms.ButtonFriend WithEvents uiClearButton As System.Windows.Forms.ButtonFriend WithEvents uiExitButton As System.Windows.Forms.ButtonFriend WithEvents uiTotalSumLabel As System.Windows.Forms.LabelFriend WithEvents uiTotalProductLabel As System.Windows.Forms.LabelFriend WithEvents uiOddEvenSumLabel As System.Windows.Forms.Label<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()Me.uiPositiveIntegerLabel = New System.Windows.Forms.LabelMe.uiSumLabel = New System.Windows.Forms.LabelMe.uiProductLabel = New System.Windows.Forms.LabelMe.uiOddEvenLabel = New System.Windows.Forms.LabelMe.uiIntegerAnswerTextBox = New System.Windows.Forms.TextBoxMe.uiGoButton = New System.Windows.Forms.ButtonMe.uiClearButton = New System.Windows.Forms.ButtonMe.uiExitButton = New System.Windows.Forms.ButtonMe.uiTotalSumLabel = New System.Windows.Forms.LabelMe.uiTotalProductLabel = New System.Windows.Forms.LabelMe.uiOddEvenSumLabel = New System.Windows.Forms.LabelMe.SuspendLayout()''uiPositiveIntegerLabel'Me.uiPositiveIntegerLabel.Location = New System.Drawing.Point(8, 8)Me.uiPositiveIntegerLabel.Name = "uiPositiveIntegerLabel"Me.uiPositiveIntegerLabel.Size = New System.Drawing.Size(104, 24)Me.uiPositiveIntegerLabel.TabIndex = 0Me.uiPositiveIntegerLabel.Text = "Positive Integer"''uiSumLabel'Me.uiSumLabel.Location = New System.Drawing.Point(8, 48)Me.uiSumLabel.Name = "uiSumLabel"Me.uiSumLabel.Size = New System.Drawing.Size(80, 24)Me.uiSumLabel.TabIndex = 2Me.uiSumLabel.Text = "Total Sum"''uiProductLabel'Me.uiProductLabel.Location = New System.Drawing.Point(8, 96)Me.uiProductLabel.Name = "uiProductLabel"Me.uiProductLabel.Size = New System.Drawing.Size(80, 24)Me.uiProductLabel.TabIndex = 4Me.uiProductLabel.Text = "Total Product"''uiOddEvenLabel'Me.uiOddEvenLabel.Location = New System.Drawing.Point(8, 136)Me.uiOddEvenLabel.Name = "uiOddEvenLabel"Me.uiOddEvenLabel.Size = New System.Drawing.Size(88, 24)Me.uiOddEvenLabel.TabIndex = 6Me.uiOddEvenLabel.Text = "Odd - Even Sum"''uiIntegerAnswerTextBox'Me.uiIntegerAnswerTextBox.Location = New System.Drawing.Point(128, 8)Me.uiIntegerAnswerTextBox.Name = "uiIntegerAnswerTextBox"Me.uiIntegerAnswerTextBox.Size = New System.Drawing.Size(104, 20)Me.uiIntegerAnswerTextBox.TabIndex = 1Me.uiIntegerAnswerTextBox.Text = ""''uiGoButton'Me.uiGoButton.Location = New System.Drawing.Point(40, 200)Me.uiGoButton.Name = "uiGoButton"Me.uiGoButton.Size = New System.Drawing.Size(72, 24)Me.uiGoButton.TabIndex = 8Me.uiGoButton.Text = "&Go"Me.uiGoButton.TextAlign = System.Drawing.ContentAlignment.TopCenter''uiClearButton'Me.uiClearButton.Location = New System.Drawing.Point(112, 200)Me.uiClearButton.Name = "uiClearButton"Me.uiClearButton.Size = New System.Drawing.Size(64, 24)Me.uiClearButton.TabIndex = 9Me.uiClearButton.Text = "&Clear"''uiExitButton'Me.uiExitButton.Location = New System.Drawing.Point(176, 200)Me.uiExitButton.Name = "uiExitButton"Me.uiExitButton.Size = New System.Drawing.Size(56, 24)Me.uiExitButton.TabIndex = 10Me.uiExitButton.Text = "&Exit"''uiTotalSumLabel'Me.uiTotalSumLabel.BackColor = System.Drawing.SystemColors.ControlMe.uiTotalSumLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingleMe.uiTotalSumLabel.Location = New System.Drawing.Point(104, 48)Me.uiTotalSumLabel.Name = "uiTotalSumLabel"Me.uiTotalSumLabel.Size = New System.Drawing.Size(80, 24)Me.uiTotalSumLabel.TabIndex = 3''uiTotalProductLabel'Me.uiTotalProductLabel.BackColor = System.Drawing.SystemColors.ControlMe.uiTotalProductLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingleMe.uiTotalProductLabel.Location = New System.Drawing.Point(104, 88)Me.uiTotalProductLabel.Name = "uiTotalProductLabel"Me.uiTotalProductLabel.Size = New System.Drawing.Size(80, 24)Me.uiTotalProductLabel.TabIndex = 5''uiOddEvenSumLabel'Me.uiOddEvenSumLabel.BackColor = System.Drawing.SystemColors.ControlMe.uiOddEvenSumLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingleMe.uiOddEvenSumLabel.Location = New System.Drawing.Point(104, 128)Me.uiOddEvenSumLabel.Name = "uiOddEvenSumLabel"Me.uiOddEvenSumLabel.Size = New System.Drawing.Size(88, 24)Me.uiOddEvenSumLabel.TabIndex = 7''uiClassPlacement'Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)Me.ClientSize = New System.Drawing.Size(292, 273)Me.Controls.Add(Me.uiOddEvenSumLabel)Me.Controls.Add(Me.uiTotalProductLabel)Me.Controls.Add(Me.uiTotalSumLabel)Me.Controls.Add(Me.uiExitButton)Me.Controls.Add(Me.uiClearButton)Me.Controls.Add(Me.uiGoButton)Me.Controls.Add(Me.uiIntegerAnswerTextBox)Me.Controls.Add(Me.uiOddEvenLabel)Me.Controls.Add(Me.uiProductLabel)Me.Controls.Add(Me.uiSumLabel)Me.Controls.Add(Me.uiPositiveIntegerLabel)Me.Name = "uiClassPlacement"Me.Text = "Form1"Me.ResumeLayout(False)End Sub#End RegionPrivate Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uiExitButton.ClickMe.Close()End SubPrivate Sub OddEvenSumLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uiOddEvenSumLabel.ClickEnd SubPrivate Sub uiClassPlacement_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadEnd SubPrivate Sub uiClearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uiClearButton.Click Me.uiIntegerAnswerTextBox.Text = ""Me.uiOddEvenSumLabel.Text = ""Me.uiTotalProductLabel.Text = ""Me.uiTotalSumLabel.Text = ""'set the focusMe.uiIntegerAnswerTextBox.Focus() End SubPrivate Sub uiGoButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uiGoButton.ClickDim num1 As IntegerDim num2 As IntegerDim totalsum As IntegerDim product As IntegerDim oddeven As IntegerDim start As Integerstart = Integer.Parse(uiIntegerAnswerTextBox.Text)num1 = Integer.Parse(uiIntegerAnswerTextBox.Text)num2 = Integer.Parse(uiIntegerAnswerTextBox.Text)Do Until num1 = 0num1 = num1 - 1num2 = num1 + num2Looptotalsum = num2Me.uiTotalSumLabel.Text = Convert.ToString(totalsum)DoLoop Until num1 <> 0Do Until num1 = 0num1 = num1 - 1num2 = num1 * num2Loopproduct = num2Me.uiTotalProductLabel.Text = Convert.ToString(product) End SubPrivate Sub uiClassPlacement_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing'verify that the user wants to exit the applicationDim button As Integerbutton = MessageBox.Show("Do you want to exit?", "Class Placement", _MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, _MessageBoxDefaultButton.Button1)'if the user selects the No button, don't close the formIf button = DialogResult.No Thene.Cancel = TrueEnd IfEnd SubEnd Class--------------------------------------------------------------------------------Reply here or PM me if you can help, thanks.
3/14/2006 9:26:57 PM
pretty sure VBA (what's included with word) ain't gonna run that
3/14/2006 9:32:00 PM
yeah, so it seems...im gonna get his version tomorrow<--- Gozo[Edited on March 14, 2006 at 10:06 PM. Reason : asdf]
3/14/2006 10:02:02 PM
friends dont let friends program in VB
3/14/2006 11:07:33 PM
Tabs would be nice. All right, this is the only part of the code that seems to be logic-related.
Private Sub uiGoButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uiGoButton.ClickDim num1 As IntegerDim num2 As IntegerDim totalsum As IntegerDim product As IntegerDim oddeven As IntegerDim start As Integerstart = Integer.Parse(uiIntegerAnswerTextBox.Text)num1 = Integer.Parse(uiIntegerAnswerTextBox.Text)num2 = Integer.Parse(uiIntegerAnswerTextBox.Text)Do Until num1 = 0num1 = num1 - 1num2 = num1 + num2Looptotalsum = num2Me.uiTotalSumLabel.Text = Convert.ToString(totalsum)DoLoop Until num1 <> 0Do Until num1 = 0num1 = num1 - 1num2 = num1 * num2Loopproduct = num2Me.uiTotalProductLabel.Text = Convert.ToString(product)End Sub
3/14/2006 11:33:24 PM
well, if your friend can't write VB, your friend probably should fail your friend's VB class
3/15/2006 3:50:41 AM
ugh vb is a horrible language to write inwhy do people still use this
3/15/2006 1:42:24 PM
The old code is supposed to add the integer the user inputs to every number less to zero. (20 + 19 +18 + 17...). The new code is supposed to multiply using the same method. I asked him about the loop thing but he said it wasn't an issue, but VB froze when he ran. No, I know I'm not good at VB, only took a semester in high school. What is everyone's issue with VB?
3/15/2006 8:57:56 PM
^vb not a c-derived language,no type-checking at compile time?true = -1 (yes i understand why this happens, but it shouldn't)oh and vb is not a c-derived languagebefore vb.net vb couldn't handle threadsno inheritance (before vb.net)i hate it and i hate having to work with a website someone decided to code in vb.netit is an ass of a language. like fortran.
3/16/2006 3:58:02 AM
The problem is his infinite loop.DoLoop Until num1 <> 0Because like 5 lines above, he makes sure num1 = 0.
3/16/2006 8:06:39 AM