How to make a text box change text automatically?

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

30 Replies - 4909 Views - Last Post: 20 March 2013 - 06:09 AM Rate Topic: -----

#1 sammy11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 01-March 13

How to make a text box change text automatically?

Posted 01 March 2013 - 01:29 PM

I am currently making a program and when the user clicks the send button the textbox automatically changes the content of the text. Is this possible?

current code is.

[b]If txt12.Text = variable Then txt11[/b]
(dont know the rest of it.
Is This A Good Question/Topic? 0
  • +

Replies To: How to make a text box change text automatically?

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3358
  • View blog
  • Posts: 11,372
  • Joined: 12-December 12

Re: How to make a text box change text automatically?

Posted 01 March 2013 - 01:33 PM

If txt12.Text = variable Then 
    txt11.Text = "Whatever"
End If


To be honest, if you don't know how to do this then you should be studying the Tutorials section, or a book, as this is fundamental knowledge for VB.NET.
Was This Post Helpful? 1
  • +
  • -

#3 IronRazer  Icon User is offline

  • D.I.C Addict

Reputation: 247
  • View blog
  • Posts: 804
  • Joined: 01-February 13

Re: How to make a text box change text automatically?

Posted 03 March 2013 - 10:39 AM

Post your code that you have and explain what you want to happen. Do you want to make (txt12.text) appear in (txt11.text) when you press the Send button. Are both textboxes on the same form? Please explain a little better so we can help. :unsure:
Was This Post Helpful? 1
  • +
  • -

#4 sammy11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 01-March 13

Re: How to make a text box change text automatically?

Posted 03 March 2013 - 12:56 PM

View Postandrewsw, on 01 March 2013 - 01:33 PM, said:

If txt12.Text = variable Then 
    txt11.Text = "Whatever"
End If



To be honest, if you don't know how to do this then you should be studying the Tutorials section, or a book, as this is fundamental knowledge for VB.NET.



yes it worked! Thanks a lot! I am a bit rusty i forgotten bits and bobs

I have a proper case now!!

I want my text box to automatically change text when i have clicked on a button to enter the password after i have inputted the password as a variable.

so for example. If i click the button set a password, an inputbox comes up i enter that password and it is stored as a variable, i have declared it. Now another text box says currently password not been set, once the password has been set i am trying to make it automatically change to password set.

this is the code i have tried already.

 Private Sub txtcpasswordstatus_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtcombination.TextChanged

If password = Text Then txtpasswordstatus.Text = "secure"

end sub
end class




this is all i can think of. I dont know what else there could be. so the above line is saying if password(variable) is text then the txtpasswordstatus.text should change from not been set to secure?

Any help would appreciate it.

I have also added the password as a variable at the top. the code is
Public Class frmthepasswordprotection

    'global variable'
    Dim combination As String = ""

Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3358
  • View blog
  • Posts: 11,372
  • Joined: 12-December 12

Re: How to make a text box change text automatically?

Posted 03 March 2013 - 01:07 PM

If password = Text

Using Text on its own refers to the forms' text (its caption). Use

If password = txtcpasswordstatus.Text


Please use sensible casing: txtCPasswordStatus. It makes your code easier to read and to spot errors.

MSDN Coding conventions

This post has been edited by andrewsw: 03 March 2013 - 01:07 PM

Was This Post Helpful? 1
  • +
  • -

#6 sammy11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 01-March 13

Re: How to make a text box change text automatically?

Posted 03 March 2013 - 01:44 PM

Hmm it doesnt work. Iv tried entering the password once i click ok on the password, the status does not change it still says not set. Iv been trying loads of diffrent codes but nothing seems to be working. And a good point about cases, iv always used lowercase because i do web development more than VB

Basically its supposed to say if password(variable) is entered then change passwordstatus to set.
Was This Post Helpful? 0
  • +
  • -

#7 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3358
  • View blog
  • Posts: 11,372
  • Joined: 12-December 12

Re: How to make a text box change text automatically?

Posted 03 March 2013 - 02:12 PM

Use
MessageBox.Show(password)
'and
MessageBox.Show(txtcpasswordstatus.Text)

before your check:
If password = txtcpasswordstatus.Text


You should investigate debugging - there is a link in my signature to a tutorial - it is an essential skill.

BTW I don't know of a language that uses entirely lowercase for identifiers(?). Maybe an older language, or a scripting tool(?).
Was This Post Helpful? 1
  • +
  • -

#8 IronRazer  Icon User is offline

  • D.I.C Addict

Reputation: 247
  • View blog
  • Posts: 804
  • Joined: 01-February 13

Re: How to make a text box change text automatically?

Posted 03 March 2013 - 02:17 PM

Is the Textbox that you want to change the text of on the same form that this code belongs to. I noticed that the form name is (frmthepasswordprotection) and wondering if you are trying to set the text of a textbox on another form from this form.
Was This Post Helpful? 1
  • +
  • -

#9 sammy11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 01-March 13

Re: How to make a text box change text automatically?

Posted 03 March 2013 - 02:25 PM

View PostIronRazer, on 03 March 2013 - 02:17 PM, said:

Is the Textbox that you want to change the text of on the same form that this code belongs to. I noticed that the form name is (frmthepasswordprotection) and wondering if you are trying to set the text of a textbox on another form from this form.


yes it on the same form. So when i click a button called set password, an inputbox will appear. then i will enter the password there. Then click ok. Then the status that says password not set should say password set. However when i click ok the status does not change from not set to set.

thanks.
Was This Post Helpful? 0
  • +
  • -

#10 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3358
  • View blog
  • Posts: 11,372
  • Joined: 12-December 12

Re: How to make a text box change text automatically?

Posted 03 March 2013 - 02:35 PM

View Postsammy11, on 03 March 2013 - 02:25 PM, said:

yes it on the same form. So when i click a button called set password, an inputbox will appear. then i will enter the password there. Then click ok. Then the status that says password not set should say password set. However when i click ok the status does not change from not set to set.

thanks.

So, after you have displayed the InputBox, and set the password, use the same statement:

If password = txtCPasswordStatus.Text Then

Was This Post Helpful? 0
  • +
  • -

#11 sammy11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 01-March 13

Re: How to make a text box change text automatically?

Posted 03 March 2013 - 03:00 PM

nope no luck... this is all my code for this section.


Private Sub btnPassword_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPassword.Click
        If txtPassword.Text = "Locked" Then
            MsgBox("You must unlock the safe before trying to change the Password", MsgBoxStyle.Information)

        Else

            Password = InputBox("Set a Password")
            If Password.Length <= 5 Then MsgBox("Must be longer than 5 characters")
            If Password= txtPasswordStatus.Text Then txtPasswordStatus.Text = "Locked"
        End If
    End Sub



BTW renamed it as suggested with caplocks so it makes sense more better.

thanks
Was This Post Helpful? 0
  • +
  • -

#12 IronRazer  Icon User is offline

  • D.I.C Addict

Reputation: 247
  • View blog
  • Posts: 804
  • Joined: 01-February 13

Re: How to make a text box change text automatically?

Posted 03 March 2013 - 04:11 PM

In the prior posts you state that (txtPasswordStatus.Text) is the textbox that has the text (secure) or (Un-secure) in it and in this line you are comparing that text to your password. Thats like asking if the new password is the same as "Unsecure".
If Password= txtPasswordStatus.Text Then txtPasswordStatus.Text = "Locked"

Are you trying to see if the password matches another password before changing the text in the textbox or do you just want it to change the text when you click the button.
Was This Post Helpful? 1
  • +
  • -

#13 sammy11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 01-March 13

Re: How to make a text box change text automatically?

Posted 03 March 2013 - 04:20 PM

View PostIronRazer, on 03 March 2013 - 04:11 PM, said:

In the prior posts you state that (txtPasswordStatus.Text) is the textbox that has the text (secure) or (Un-secure) in it and in this line you are comparing that text to your password. Thats like asking if the new password is the same as "Unsecure".
If Password= txtPasswordStatus.Text Then txtPasswordStatus.Text = "Locked"

Are you trying to see if the password matches another password before changing the text in the textbox or do you just want it to change the text when you click the button.


No im trying to change the text when you click the button and have entered somthing. I dont want someone to click the button but not enter any text and cancel it and the text changes. I want the text to change if the user enters somthing in the text box.

Thanks

View Postsammy11, on 03 March 2013 - 04:19 PM, said:

View PostIronRazer, on 03 March 2013 - 04:11 PM, said:

In the prior posts you state that (txtPasswordStatus.Text) is the textbox that has the text (secure) or (Un-secure) in it and in this line you are comparing that text to your password. Thats like asking if the new password is the same as "Unsecure".
If Password= txtPasswordStatus.Text Then txtPasswordStatus.Text = "Locked"

Are you trying to see if the password matches another password before changing the text in the textbox or do you just want it to change the text when you click the button.


No im trying to change the text when you click the button and have entered somthing. I dont want someone to click the button but not enter any text and cancel it and the text changes. I want the text to change if the user enters somthing in the text box.

Thanks


I meant inputbox not text box sorry.
Was This Post Helpful? 0
  • +
  • -

#14 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3358
  • View blog
  • Posts: 11,372
  • Joined: 12-December 12

Re: How to make a text box change text automatically?

Posted 03 March 2013 - 04:30 PM

I think you should re-read IronRazer 's post. You are comparing Password to txtPasswordStatus.Text which, even without other information, seems wrong. Surely you should be comparing Password to txtPassword.Text?

And why would txtPassword.Text be "Locked" - surely it should contain the password.
Was This Post Helpful? 1
  • +
  • -

#15 IronRazer  Icon User is offline

  • D.I.C Addict

Reputation: 247
  • View blog
  • Posts: 804
  • Joined: 01-February 13

Re: How to make a text box change text automatically?

Posted 03 March 2013 - 04:32 PM

Here try this. If its not longer that 5 characters it will tell you and if a password longer than 5 characters is entered it changes textbox text to Locked.
    Private Sub btnPassword_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPassword.Click
        If txtPassword.Text = "Locked" Then
            MsgBox("You must unlock the safe before trying to change the Password", MsgBoxStyle.Information)

        Else

            Password = InputBox("Set a Password")

            If password.Length <= 5 Then
                MsgBox("Must be longer than 5 characters")
            Else
                If password <> "" Then txtPassword.Text = "Locked"
            End If

        End If
    End Sub


Was This Post Helpful? 1
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3