custom home project

  • (2 Pages)
  • +
  • 1
  • 2

23 Replies - 2554 Views - Last Post: 14 October 2012 - 01:04 PM Rate Topic: -----

#16 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 583
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: custom home project

Posted 12 October 2012 - 11:25 PM

View Postcharyl, on 12 October 2012 - 03:16 PM, said:

Well hello there stranger!
Thanks that worked for that. I'm on line 81 and I've just reached the CloseToolStripMenuItem, we'll see... Hard to believe this is the easy part...OMGosh...I'm so screwed.

This is only the part to save the estimate. I have not even started on the work to preform the estimate and I will have little or no code to go on...I'll try using past projects. One thing I'm not sure of when I get there I need to string the total estimate cost to this that I'm working on now. I have not figured out the TryParse yet. DimitriV if you have a second look up Duplicate Elimination I posted on this week and tell me if there's coding you can figure out to use the TryParse. Just so I can try it on an old project instead of messing a new one up first. If you don't have time...I completely understand! Good to see you. Loved your pic. Love Spiderman too :).

Great to see you back too, charyl. I'll have a look but I can pretty much explain TryParse here:
Dim result As Integer
Dim input As String = "789823"
Dim success As Boolean = Integer.TryParse(input, result)
If success = True Then
'work what ever you were going to do here
End If


I'll stick it in both. Good old trevster344, all the great ideas. :)

Reference: http://msdn.microsof...02979c7.aspx#Y0
Was This Post Helpful? 1
  • +
  • -

#17 charyl  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 324
  • Joined: 29-June 11

Re: custom home project

Posted 13 October 2012 - 02:34 PM

Question on Gui: would like the option of categorizing products that will be purchased...Will this be Lumber, Electical, Heating and Air, Doors and Windows...Labor...Should I use a combo list box, list box or maybe radio buttons, that asks the question what would you like this under?
Was This Post Helpful? 0
  • +
  • -

#18 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2250
  • View blog
  • Posts: 9,433
  • Joined: 29-May 08

Re: custom home project

Posted 13 October 2012 - 04:06 PM

View PostDimitriV, on 13 October 2012 - 07:25 AM, said:

Great to see you back too, charyl. I'll have a look but I can pretty much explain TryParse here:
Dim result As Integer
Dim input As String = "789823"
Dim success As Boolean = Integer.TryParse(input, result)
If success = True Then
'work what ever you were going to do here
End If



success is a Boolean, so no need for the comparison = True

Also if your not reusing success anywhere else just do.
Dim result As Integer
Dim input As String = "789823"
If Integer.TryParse(input, result) Then


Was This Post Helpful? 1
  • +
  • -

#19 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 583
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: custom home project

Posted 13 October 2012 - 05:06 PM

View Postcharyl, on 14 October 2012 - 08:34 AM, said:

Question on Gui: would like the option of categorizing products that will be purchased...Will this be Lumber, Electical, Heating and Air, Doors and Windows...Labor...Should I use a combo list box, list box or maybe radio buttons, that asks the question what would you like this under?

You could use a whole lot of things, try maybe a Panel. You can then put whatever you want into them.
But before I go ahead and tell you how to do things in a GUI, you've got the coding mostly finished? If so, could I have a look at what you're kind of trying to do with your GUI so I can better advise things for you? (Sorry if that didn't make sense)
Was This Post Helpful? 1
  • +
  • -

#20 charyl  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 324
  • Joined: 29-June 11

Re: custom home project

Posted 13 October 2012 - 09:05 PM

Sorry I got off on some OCD tangent on inserting the date and have waisted so much time learning all the different ways that I'm more confused than ever. And I've messed with my code so much I have too many problems, I'm sure they are all simple, it was a matter of too much information and not knowing what to do with all of it and too much code that could be added and not knowing wich code to use for what...blah, Do I use a lable for a date? I'm so confused right now... Here are my errors now: If I erase everything I can go back to account number not valid, wich Mod made sense, but I got off into so many different needs I still had not met that I moved foward without fixing what I needed to begin with. Do you know what the code is to insert current date and save it to the form? Do I use a lable or a text box? I would prefer not to use a button and have it just insert automatically,?

Error 1 Array bounds cannot appear in type specifiers. H:\school\2012\VisualBasics\midterm_infor\Cjanney_Midterm\Cjanney_Midterm\CreateAccount.vb 7 37 CreateAccounts
Error 2 Local variable 'intPONumberTextBox' is already declared in the current block. H:\school\2012\VisualBasics\midterm_infor\Cjanney_Midterm\Cjanney_Midterm\CreateAccount.vb 84 13 CreateAccounts
Error 3 Argument not specified for parameter 'e' of 'Private Sub addAccountButton_Click(sender As Object, e As System.EventArgs)'. H:\school\2012\VisualBasics\midterm_infor\Cjanney_Midterm\Cjanney_Midterm\CreateAccount.vb 87 12 CreateAccounts
Error 4 Argument not specified for parameter 'sender' of 'Private Sub addAccountButton_Click(sender As Object, e As System.EventArgs)'. H:\school\2012\VisualBasics\midterm_infor\Cjanney_Midterm\Cjanney_Midterm\CreateAccount.vb 87 12 CreateAccounts
Error 5 Property access must assign to the property or use its value. H:\school\2012\VisualBasics\midterm_infor\Cjanney_Midterm\Cjanney_Midterm\CreateAccount.vb 95 14 CreateAccounts
Error 6 Expression expected. H:\school\2012\VisualBasics\midterm_infor\Cjanney_Midterm\Cjanney_Midterm\CreateAccount.vb 95 30 CreateAccounts
Error 7 Method arguments must be enclosed in parentheses. H:\school\2012\VisualBasics\midterm_infor\Cjanney_Midterm\Cjanney_Midterm\CreateAccount.vb 95 30 CreateAccounts


'Program that creates a text file of account information
Imports System.IO

Public Class CreateAccount

    Dim addAccountButton As String (txtDate, lastNameTextBox, firstNameTextBox, PONumberTextBox, estimatedCostTextBox)
    ' Writes data totext file
    Dim fileWriter As StreamWriter
    'Private NewToolStripMenuItem As Char


    Private Sub ExistingEstimateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExistingEstimateToolStripMenuItem.Click

        Dim result As DialogResult
        Dim fileName As String      'Name of file to save data
        'Dim lblPONumber As String

        Using fileChooser As New OpenFileDialog()
            result = fileChooser.ShowDialog()
            fileName = fileChooser.FileName
        End Using

    End Sub

    'Create a new file in which accounts can be stored
    Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click

        'ensure that any prior file is closed

        'CloseFile()
        Dim result As DialogResult  'Stores result of Save dialog
        Dim fileName As String      'Name of file to save data
        'Dim PONumberTextBox As String
        Dim intPONumberTextBox As String = CStr(0)
        'Dim PONumberTextBox As String

        If IsNumeric(intPONumberTextBox.Trim()) Then

        End If

        If CDbl(intPONumberTextBox) >= 0 Then

            MessageBox.Show("Please enter a Purchase Order Number.")
        End If

        'Display dialog so user can choose the name of the file to save
        Using fileChooser As New SaveFileDialog()
            result = fileChooser.ShowDialog()
            fileName = fileChooser.FileName  'get specified file name
        End Using               'Automatica call to fileCooser.Dispose() occureshere

        ' if user did not click Cancel
        If result <> Windows.Forms.DialogResult.Cancel Then

            Try
                'open or create file for writing
                fileWriter = New StreamWriter(fileName, True)

                'enable controls
                ExistingEstimateToolStripMenuItem.Enabled = True
                CloseToolStripMenuItem.Enabled = True
                addAccountButton.Enabled = True
                'PONumberTextBox.Enabled = True
                firstNameTextBox.Enabled = True
                lastNameTextBox.Enabled = True
                estimatedCostTextBox.Enabled = True

            Catch ex As IOException

                MessageBox.Show("Error Opening File", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

            End Try
        End If
    End Sub


    Private Sub addAccountButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addAccountButton.Click, btnItem.Click

        'determine whether TextBox account field is empty
        Dim result As DialogResult  'Stores result of Save dialog
        Dim fileName As String      'Name of file to save data
        Dim intPONumberTextBox As String
        Dim intPONumberTextBox = PONumberTextBox
        Dim dtmTest As Date

        If addAccountButton_Click() Then

        End If
        dtmTest = TimeValue(CStr(Now))
        'Dim PONumberTextBox As String


        If CInt(IsNumeric(PONumberTextBox)) >= 0 Then
             PONumberTextBox <> String.Empty Then
            MessageBox.Show("Please enter a PO number.")
        End If

        'Try to store record to file
        Try
            Dim PONumberTextBox As Integer = Convert.ToInt32(PONumberTextBox) 'gets account number

            If PONumberTextBox > 0 Then 'Valid account number?
                'wtite record data to file separatingfields by commas
                fileWriter.WriteLine(PONumberTextBox & "," &
                firstNameTextBox.Text & "," &
                lastNameTextBox.Text & "," &
                Convert.ToDecimal(estimatedCostTextBox))
            Else
                MessageBox.Show("Invalid Account Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

            End If
        Catch ex As IOException
            MessageBox.Show("ErrorToString Writing to File", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Catch ex As FormatException
            MessageBox.Show("Invalid Account Number", "Format Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

        End Try



        PONumberTextBox.Clear()
        firstNameTextBox.Clear()
        lastNameTextBox.Clear()
        estimatedCostTextBox.Clear()
        PONumberTextBox.Focus()
    End Sub    'addNewAccountButton_Click


    Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click

        'CloseFile() ' Closes currently open file
        CloseToolStripMenuItem.Enabled = False
        addAccountButton.Enabled = False
        PONumberTextBox.Enabled = False
        firstNameTextBox.Enabled = False
        lastNameTextBox.Enabled = False
        estimatedCostTextBox.Enabled = False
    End Sub 'CloseToolStripMenuItem_Click

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        ' Exit the application
        'SubCloseFile()
        If fileWriter IsNot Nothing Then
            Try
                fileWriter.Close() 'close StreamWriter
            Catch ex As IOException
                MessageBox.Show("Error closing file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Application.Exit()
            End Try
        End If
    End Sub


    Private Sub txtDate_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDate.TextChanged
        Dim dtmTest As Date

        dtmTest = TimeValue(CStr(Now))

    End Sub
End Class






Sorry I got off on some OCD tangent on inserting the date and have waisted so much time learning all the different ways that I'm more confused than ever. And I've messed with my code so much I have too many problems, I'm sure they are all simple, it was a matter of too much information and not knowing what to do with all of it and too much code that could be added and not knowing wich code to use for what...blah, Do I use a lable for a date? I'm so confused right now... Here are my errors now: If I erase everything I can go back to account number not valid, wich Mod made sense, but I got off into so many different needs I still had not met that I moved foward without fixing what I needed to begin with. Do you know what the code is to insert current date and save it to the form? Do I use a lable or a text box? I would prefer not to use a button and have it just insert automatically,?

Error 1 Array bounds cannot appear in type specifiers. H:\school\2012\VisualBasics\midterm_infor\Cjanney_Midterm\Cjanney_Midterm\CreateAccount.vb 7 37 CreateAccounts
Error 2 Local variable 'intPONumberTextBox' is already declared in the current block. H:\school\2012\VisualBasics\midterm_infor\Cjanney_Midterm\Cjanney_Midterm\CreateAccount.vb 84 13 CreateAccounts
Error 3 Argument not specified for parameter 'e' of 'Private Sub addAccountButton_Click(sender As Object, e As System.EventArgs)'. H:\school\2012\VisualBasics\midterm_infor\Cjanney_Midterm\Cjanney_Midterm\CreateAccount.vb 87 12 CreateAccounts
Error 4 Argument not specified for parameter 'sender' of 'Private Sub addAccountButton_Click(sender As Object, e As System.EventArgs)'. H:\school\2012\VisualBasics\midterm_infor\Cjanney_Midterm\Cjanney_Midterm\CreateAccount.vb 87 12 CreateAccounts
Error 5 Property access must assign to the property or use its value. H:\school\2012\VisualBasics\midterm_infor\Cjanney_Midterm\Cjanney_Midterm\CreateAccount.vb 95 14 CreateAccounts
Error 6 Expression expected. H:\school\2012\VisualBasics\midterm_infor\Cjanney_Midterm\Cjanney_Midterm\CreateAccount.vb 95 30 CreateAccounts
Error 7 Method arguments must be enclosed in parentheses. H:\school\2012\VisualBasics\midterm_infor\Cjanney_Midterm\Cjanney_Midterm\CreateAccount.vb 95 30 CreateAccounts


'Program that creates a text file of account information
Imports System.IO

Public Class CreateAccount

    Dim addAccountButton As String (txtDate, lastNameTextBox, firstNameTextBox, PONumberTextBox, estimatedCostTextBox)
    ' Writes data totext file
    Dim fileWriter As StreamWriter
    'Private NewToolStripMenuItem As Char


    Private Sub ExistingEstimateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExistingEstimateToolStripMenuItem.Click

        Dim result As DialogResult
        Dim fileName As String      'Name of file to save data
        'Dim lblPONumber As String

        Using fileChooser As New OpenFileDialog()
            result = fileChooser.ShowDialog()
            fileName = fileChooser.FileName
        End Using

    End Sub

    'Create a new file in which accounts can be stored
    Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click

        'ensure that any prior file is closed

        'CloseFile()
        Dim result As DialogResult  'Stores result of Save dialog
        Dim fileName As String      'Name of file to save data
        'Dim PONumberTextBox As String
        Dim intPONumberTextBox As String = CStr(0)
        'Dim PONumberTextBox As String

        If IsNumeric(intPONumberTextBox.Trim()) Then

        End If

        If CDbl(intPONumberTextBox) >= 0 Then

            MessageBox.Show("Please enter a Purchase Order Number.")
        End If

        'Display dialog so user can choose the name of the file to save
        Using fileChooser As New SaveFileDialog()
            result = fileChooser.ShowDialog()
            fileName = fileChooser.FileName  'get specified file name
        End Using               'Automatica call to fileCooser.Dispose() occureshere

        ' if user did not click Cancel
        If result <> Windows.Forms.DialogResult.Cancel Then

            Try
                'open or create file for writing
                fileWriter = New StreamWriter(fileName, True)

                'enable controls
                ExistingEstimateToolStripMenuItem.Enabled = True
                CloseToolStripMenuItem.Enabled = True
                addAccountButton.Enabled = True
                'PONumberTextBox.Enabled = True
                firstNameTextBox.Enabled = True
                lastNameTextBox.Enabled = True
                estimatedCostTextBox.Enabled = True

            Catch ex As IOException

                MessageBox.Show("Error Opening File", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

            End Try
        End If
    End Sub


    Private Sub addAccountButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addAccountButton.Click, btnItem.Click

        'determine whether TextBox account field is empty
        Dim result As DialogResult  'Stores result of Save dialog
        Dim fileName As String      'Name of file to save data
        Dim intPONumberTextBox As String
        Dim intPONumberTextBox = PONumberTextBox
        Dim dtmTest As Date

        If addAccountButton_Click() Then

        End If
        dtmTest = TimeValue(CStr(Now))
        'Dim PONumberTextBox As String


        If CInt(IsNumeric(PONumberTextBox)) >= 0 Then
             PONumberTextBox <> String.Empty Then
            MessageBox.Show("Please enter a PO number.")
        End If

        'Try to store record to file
        Try
            Dim PONumberTextBox As Integer = Convert.ToInt32(PONumberTextBox) 'gets account number

            If PONumberTextBox > 0 Then 'Valid account number?
                'wtite record data to file separatingfields by commas
                fileWriter.WriteLine(PONumberTextBox & "," &
                firstNameTextBox.Text & "," &
                lastNameTextBox.Text & "," &
                Convert.ToDecimal(estimatedCostTextBox))
            Else
                MessageBox.Show("Invalid Account Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

            End If
        Catch ex As IOException
            MessageBox.Show("ErrorToString Writing to File", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Catch ex As FormatException
            MessageBox.Show("Invalid Account Number", "Format Error", MessageBoxButtons.OK, MessageBoxIcon.Error)

        End Try



        PONumberTextBox.Clear()
        firstNameTextBox.Clear()
        lastNameTextBox.Clear()
        estimatedCostTextBox.Clear()
        PONumberTextBox.Focus()
    End Sub    'addNewAccountButton_Click


    Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click

        'CloseFile() ' Closes currently open file
        CloseToolStripMenuItem.Enabled = False
        addAccountButton.Enabled = False
        PONumberTextBox.Enabled = False
        firstNameTextBox.Enabled = False
        lastNameTextBox.Enabled = False
        estimatedCostTextBox.Enabled = False
    End Sub 'CloseToolStripMenuItem_Click

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        ' Exit the application
        'SubCloseFile()
        If fileWriter IsNot Nothing Then
            Try
                fileWriter.Close() 'close StreamWriter
            Catch ex As IOException
                MessageBox.Show("Error closing file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                Application.Exit()
            End Try
        End If
    End Sub


    Private Sub txtDate_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDate.TextChanged
        Dim dtmTest As Date

        dtmTest = TimeValue(CStr(Now))

    End Sub
End Class





Was This Post Helpful? 0
  • +
  • -

#21 charyl  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 324
  • Joined: 29-June 11

Re: custom home project

Posted 13 October 2012 - 09:20 PM

The second thing Off the OCD thing is

A. When you hit the existing estimate it should be saved: Not sure how to save. you should be able to call on it with a name or po
B. When you hit the new button It should ask you for a PO #, then a last name, then a first name and the date should come in automatically, then it should ask what products (items) you would like to add then where would you like to store it...Lumber, windows and doors, misc...

I need to get myself back on track, there's just so much to learn and not enough time.

This post has been edited by charyl: 13 October 2012 - 09:23 PM

Was This Post Helpful? 0
  • +
  • -

#22 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 583
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: custom home project

Posted 13 October 2012 - 09:34 PM

What's going on with the If Button_Click Then bit? Sorry, I'll have to come back later, having trouble.

This post has been edited by DimitriV: 13 October 2012 - 10:58 PM

Was This Post Helpful? 1
  • +
  • -

#23 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 583
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: custom home project

Posted 13 October 2012 - 11:13 PM

This line:
Convert.ToDecimal(estimatedCostTextBox))
Should be:
Convert.ToDecimal(estimatedCostTextBox.Text)
Was This Post Helpful? 1
  • +
  • -

#24 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 583
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: custom home project

Posted 14 October 2012 - 01:04 PM

Hey again:
PONumberTextBox <> String.Empty Then
'Code


That bit needs an If.

Have the date insert automatically? Sure, you can do that without a button but it will have to be triggered by an event of some sort. When should the date appear?

Ha! The topic has been featured on the main page :D
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2