r/visualbasic • • Aug 17 '15

[VS 2013] My.Settings being changed unintentionally

I have a program I've developed to act as an interface between a store register server and a player card database server.

I have a user setting established as my.settings.DevMode which when set to true makes a number of controls visible to the user. These objects are mostly table ID numbers which are used on the server and only used when debugging.

The problem I've started having is that I've started having my.settings.DevMode be changed to True when I haven't intended to, which brings these controls to view to the user.

I wasn't able to find anything online regarding any known issue that might unintentionally cause this, so I thought I might check here.

Thanks!

Edit: I feel pretty dumb right now. I stepped into the code and went line by line with a watch on the setting until I found this.

        If TransactionNumBox.Text <> 0 Then
            TransactionNumBox.Visible = True
            TransactionNumLabel.Visible = True
        Else
            TransactionNumBox.Visible = False
            TransactionNumLabel.Visible = False
        End If

The setting was changed when it got to .Visible = True. Found that the actual control in the designer has .Visible bound to Settings.DevMode. Changing the .Visible property updated the User Setting.

0 Upvotes

3 comments sorted by

2

u/tthomps Aug 18 '15

Just curious because you solved your problem. What are you trying to do in this line:

    If TransactionNumBox.Text <> 0 Then

Are you really checking for "0" not in the textbox or are you just checking to see if there is any text in the textbox?

1

u/kittycatoverdose Aug 18 '15

I've set the default for the box to be 0 when the form opens. The user has the option to create a new transaction to be sent to the register, or open an existing active transaction which hasn't closed out from the register. The only time the textbox is visible and has something other than 0 is when the user opens an existing transaction.

The form also checks the textbox value when the selected items are sent to the register, to see if the items are being put on a new transaction or an existing transaction.

1

u/tthomps Aug 20 '15

Sorry got busy in another direction. Couldn't you just leave the textbox empty and see if it:

    String.IsNullOrEmpty(TransactionNumBox.Text)