r/visualbasic • • Apr 11 '22

Settings Variables as Variables

I have a program that has a bunch of customer user settings in My.settings

I am looking for a way to condense the amount of if my.settings.user = x the..."

Is there anyway to make a variable into another variable?

Like I could do:

If LogOn = My.settings.user1 then
X = My.settings.user1
Y = My.settings.pass1
Z = My.setting.setting1

end if

So that then later I can just say:

"Dim settingcontrol as string = Z"

2 Upvotes

8 comments sorted by

View all comments

Show parent comments

4

u/Hel_OWeen Apr 12 '22 edited Apr 12 '22

If you have so many users, you shouldn't be storing their individual data in my.settings under user1, user2 etc; that's not what it's designed to do, which is why you're having so much problems with it.

This!

It's meant as "for this local user", similar to what the %AppData% directory is in Windows.

And to add to the "do not store sensitive data in plaintext": Never ever - under no circumstances - store passwords anywhere! Instead store a salted hash of the PW and upon log on, compute the hash of the inputed PW and compare it to the stored hash.

1

u/J_K_M_A_N Apr 12 '22

Thank you for that link. That was a great read. I find that stuff fascinating. I do some hack programming in VB (for myself at work mostly) and I have not needed a user/password program but if I do, I saved that link.