By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,990 Members | 2,324 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,990 IT Pros & Developers. It's quick & easy.

Changing a public string

P: n/a
I have this line of code
Public Navn1 As String = "Per"

I want to change it to another 'text' by entering some text in a textbox
like

navn1 = 'Nils'

and then the line should look like

Public Navn1 As String = "Nils"

How do I do that?

regards

reidarT
Nov 21 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
I am not sure if I understand your question. But if you want to change the
value that is stored in the string, when you enter something in a textbox.
Write code in one of the Textboxe's events (Exit, TextChanged) to set the
value of the string as
navn1 =Textbox1.Text.

--
Rgds,
Anand
VB.NET MVP
http://www.dotnetindia.com
"ReidarT" wrote:
I have this line of code
Public Navn1 As String = "Per"

I want to change it to another 'text' by entering some text in a textbox
like

navn1 = 'Nils'

and then the line should look like

Public Navn1 As String = "Nils"

How do I do that?

regards

reidarT

Nov 21 '05 #2

P: n/a
Yes I can see this, but I want the public string to change so that the next
time I open the form it contains the new value/text.
regards
reidarT

"Anand[MVP]" <An******@discussions.microsoft.com> skrev i melding
news:C7**********************************@microsof t.com...
I am not sure if I understand your question. But if you want to change the
value that is stored in the string, when you enter something in a textbox.
Write code in one of the Textboxe's events (Exit, TextChanged) to set the
value of the string as
navn1 =Textbox1.Text.

--
Rgds,
Anand
VB.NET MVP
http://www.dotnetindia.com
"ReidarT" wrote:
I have this line of code
Public Navn1 As String = "Per"

I want to change it to another 'text' by entering some text in a textbox
like

navn1 = 'Nils'

and then the line should look like

Public Navn1 As String = "Nils"

How do I do that?

regards

reidarT

Nov 21 '05 #3

P: n/a
Reidar,
Public Navn1 As String = "Per"
I want to change it to another 'text' by entering some text in a textbox
like
navn1 = 'Nils'
and then the line should look like
Public Navn1 As String = "Nils"
How do I do that?


If I would dot this as you ask, than I would use probably something as this
code in the leave or validating event of the textbox

If mytextbox.text = "navn1" then
navn1 = replace.mytextbox.text(navn1 = ',"")
navn1 = replace.mytextbox.text("'","")
end if

However I would never do things like this. It gives only misunderstandings
and not resolved errors.

I hope this helps,

Cor
Nov 21 '05 #4

P: n/a
ReidarT wrote:
Yes I can see this, but I want the public string to change so that the next
time I open the form it contains the new value/text.
regards
reidarT


You want to change the sourcecode when running the program? I think
you'd be better off saving things like these to a config file or
database. Then when opening the form you read the default value for that
variable from the config file/database.
--
Rinze van Huizen
C-Services Holland b.v.
Nov 21 '05 #5

P: n/a
Reidar,

As I understand now from Rinze, do you mean in your code?

Cor
Nov 21 '05 #6

P: n/a
I know I can use a config.file, but I thought it would be easier if I had a
form to change a public value.
If I wanted to change the default username, or something like that.
regards
reidarT
"Cor Ligthert" <no************@planet.nl> skrev i melding
news:ee**************@TK2MSFTNGP12.phx.gbl...
Reidar,

As I understand now from Rinze, do you mean in your code?

Cor

Nov 21 '05 #7

P: n/a

"C-Services Holland b.v." <cs*@REMOVEcsh4u.nl> wrote in message
news:hr********************@zeelandnet.nl...
ReidarT wrote:
Yes I can see this, but I want the public string to change so that the
next time I open the form it contains the new value/text.
regards
reidarT


You want to change the sourcecode when running the program? I think you'd
be better off saving things like these to a config file or database. Then
when opening the form you read the default value for that variable from
the config file/database.
--
Rinze van Huizen
C-Services Holland b.v.


Why not save it in the registry? It sounds to me like you don't need
something that actually changes the code, but checks to see what the latest
value was the last time the form was opened.

Dave
Nov 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.