I erased some code but its still executing...

rusty

Member
Joined
May 10, 2010
Messages
9
Programming Experience
Beginner
I've been writing this atm program on my spare time (with your help). I just finished logging in to the database, but I encountered a problem I haven't seen before in any program I've ever coded. I'm using panels to change screens and move around. I initially wrote the design of the program and then started writing the code. Initially for the login I had written a hide panel and show panel just to test some things out. I erased that code to write the login check and it is still just hiding the panel and showing the next, even though I erased it. So I erased most of the code throughout and replaced it with some msgbox codes to do some testing. The entire program, no matter what part (load, button clicks, etc), isn't running any of the new code. Any ideas???? I'm currently re-writing the whole program. Is there a quick way to do backups of programs? Currently I'm copying the folder and changing the names of the files. Thanks...
 
Are there any compile errors? When you erase code using there's 1 or more compile errors and if you dont take care of them then every time you run the program you're running the last successful compile, which means it's the program without the erased changes.
 
I have 2 option strict conversions from object to textbox. Both concerning the "sender" on the last two lines. I'm validating the text to make sure they are numbers...
VB.NET:
'Keeps user from entering anything but numbers
    Dim charactersDisallowed As String = "`~!@#$%^&*()_+-={}|[]\:;<,>.?/'qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM"""

'checks the text that the user enters for the card number
Private Sub txtCustCardNumber_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCustCardNumber.TextChanged

        Dim theText As String = txtCustCardNumber.Text
        Dim Letter As String
        Dim SelectionIndex As Integer = txtCustCardNumber.SelectionStart
        Dim Change As Integer

        For x As Integer = 0 To txtCustCardNumber.Text.Length - 1
            Letter = txtCustCardNumber.Text.Substring(x, 1)
            If charactersDisallowed.Contains(Letter) Then
                theText = theText.Replace(Letter, String.Empty)
                Change = 1
            End If
        Next

        txtCustCardNumber.Text = theText
        txtCustCardNumber.Select(SelectionIndex - Change, 0)
    End Sub

    'checks the text that the user enters for the pin number
    Private Sub txtCustCardPin_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCustCardPin.TextChanged

        Dim theText As String = txtCustCardPin.Text
        Dim Letter As String
        Dim SelectionIndex As Integer = txtCustCardPin.SelectionStart
        Dim Change As Integer

        For x As Integer = 0 To txtCustCardPin.Text.Length - 1
            Letter = txtCustCardPin.Text.Substring(x, 1)
            If charactersDisallowed.Contains(Letter) Then
                theText = theText.Replace(Letter, String.Empty)
                Change = 1
            End If
        Next
        txtCustCardPin.Text = theText
        txtCustCardPin.Select(SelectionIndex - Change, 0)
    End Sub

****I THINK THAT THIS IS THE LINE I'M HAVING TROUBLE WITH...***

Private currentTextBox As New TextBox


Private Sub txtCustCardNumber_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtCustCardNumber.GotFocus
        currentTextBox = sender
End Sub

Private Sub txtCustCardPin_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtCustCardPin.GotFocus
        currentTextBox = sender
End Sub

I see what you are saying about the compile errors. I turned off option strict and the code is working differently. Awesome! I still have the two option strict errors that I need to fix, but at least there is a bit of stress off my shoulders.
 
Last edited:
If I make a mistake when coding and the code won't compile, but I press Play anyway, I see a message:

Your project doesnt currently build. Do you want to run the last version that successfully built?

If I say Yes to this dialog, then the old version of the program runs, which naturally doesnt include my changes..
 
Back
Top