Question How do I get an InputBox to open if a setting has not saved anything?

Raymond9654

New member
Joined
Mar 8, 2011
Messages
3
Programming Experience
Beginner
Ok....
I have this neat little web browser that has recently been gaining a bit of speed in download rates because of it's ability to change proxies by the click of a button. None of this is important, I'm just giving you backround info.

I want to make the program a little bit.. spiffier and cooler.
I thought it would be cool if the program could refer to you by name so I want an inputbox to open up if there is no fname saved to a setting and ask for your name.

Right now I have
VB.NET:
If My.Settings.fname = clear Then
Dim fname
fname = InputBox("What is your name?")
My.Settings.fname.Add(fname)
My.Settings.Save()
End If

This is what I have so far.
I believe it would work except for the but "If My.Settings.fname = clear Then" because the setting being clear is not a clear command.

How would you say if the setting doesn't have anything saved to it then execute the following command?

This is important for a school project and for my friends who told me that I couldn't do this, so I really need an answer.

Thanks!
 
Clear isn't a keyword.
Try using the following instead:

VB.NET:
If String.IsNullOrEmpty(My.Settings.fname) Then
 
Clear isn't a keyword.
Try using the following instead:

VB.NET:
If String.IsNullOrEmpty(My.Settings.fname) Then


That fixed one problem but caused another.

Should I change the setting to a string rather than System.Collection.... etc.?

If then how do I add the fname to the setting?
 
Yes, the name would have to be a string. A system.collection would be using in something like a list box.
Here is how you could do it:
VB.NET:
If My.Settings.fname = "" Then
Dim fname as string
fname = InputBox("What is your name?")
My.Settings.fname = fname
My.Settings.Save()
End if
 
Yes, the name would have to be a string. A system.collection would be using in something like a list box.
Here is how you could do it:
VB.NET:
If My.Settings.fname = "" Then
Dim fname as string
fname = InputBox("What is your name?")
My.Settings.fname = fname
My.Settings.Save()
End if

That's how I do it in LimeEdit.

The code works well but I can't get a label to display the fname
 
Lets say the label name is 'fnamelbl'
VB.NET:
fnamelbl.text = My.Settings.fname
That should work fine.

You would put that on form load and right after they enter their name.
I would also make a setting for them to change their name.
Add a button and name it 'cname', and change its text to Change Name (Or whatever)
VB.NET:
Private Sub cname_click() handles cname.click

Dim fname as string
fname = InputBox("What is your name?")
My.Settings.fname = fname
My.Settings.Save()

End sub
 
Last edited:
Back
Top