Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

TextBox1_KeyPress

  Asked By: Armando    Date: Jan 07    Category: MS Office    Views: 749
  

i have a problem about textbox. I want to automatic
display when i write some words at textbox1 and also i
have a answer in textbox2.
The code I wrote to create is

Private Sub TextBox1_KeyPress(ByVal KeyAscii As
MSForms.ReturnInteger)

If TextBox1 = " ASK " Then
TextBox2.Value = " True "
Else
TextBox2.Value = " false "
End If


End Sub

Share: 

 

12 Answers Found

 
Answer #1    Answered By: Herbert Weaver     Answered On: Jan 07

Are you aware you have surplus spaces in your strings? That could be
giving you problems. Your code  will run fine if you strip out the spaces
and put it instead in the AfterUpdate event of the text box.

 
Answer #2    Answered By: Richie Smith     Answered On: Jan 07

I'm sorry i still confuse about your answer. Can you
write the code  true. i'm not advanced about ms excell.

 
Answer #3    Answered By: Emma Brown     Answered On: Jan 07

Take all the spaces out from inside your quotes. Then change the name of
the routine from this:

Private Sub TextBox1_KeyPress(ByVal KeyAscii As
MSForms.ReturnInteger)

To this:

Private Sub TextBox1_AfterUpdate

 
Answer #4    Answered By: Willie Gomez     Answered On: Jan 07

The macro worked
exactly as you
posted.Btw, now i try another example again. I have
some number at worksheets. I want write  to textbox1,
and i hope, at textbox2 otomatic write some number
before a number at textbox1 match to activeworksheets
And The code  I wrote to create  is, but not working
properly.

Private Sub TextBox1_AfterUpdate()
If TextBox1.Value = Worksheets(1).Range(a1) And
Worksheets(1).Range(a5) Then
TextBox2.Value = Worksheets(1).Range(b1) And
Worksheets(1).Range(b5)

Else
TextBox2.Value = Worksheets(1).Range(c1) And
Worksheets(1).Range(c5)
End If

End Sub

 
Answer #5    Answered By: Pravat Jainukul     Answered On: Jan 07

Sorry not to have responded to this one sooner, but it was caught in my
ISP's s-p-a-m filter for some reason.

Your problem  is that your Range references all need to be in quotes,
e.g. Range("A1")

 
Answer #6    Answered By: Rocco Anderson     Answered On: Jan 07

TotalPrice 'Calls the Total Price Function..............

 
Answer #7    Answered By: Scott Simmons     Answered On: Jan 07

I'm sure there's a better way without activating/selecting - but this works
until you get something tidier!

Sub insert2rows()

Dim wkSheet As Worksheet

For Each wkSheet In ActiveWorkbook.Worksheets
wkSheet.Activate
Range("B1").Select
Selection.EntireColumn.Insert
Range("A1").Select
Selection.EntireColumn.Insert
Next wkSheet
End Sub

 
Answer #8    Answered By: Raju Srinivas     Answered On: Jan 07

here's one way:
replace:

wkSheet.Activate
Range("B1").Select
Selection.EntireColumn.Insert
Range("A1").Select
Selection.EntireColumn.Insert

with:

wkSheet.Range("A:B").EntireColumn.Insert

 
Answer #9    Answered By: Neil Turner     Answered On: Jan 07

Your solution adds two columns before Column A while the
other example adds a blank column before column A and a blank column before
column B.

 
Answer #10    Answered By: Katrina Edwards     Answered On: Jan 07

You're quite right; change my:

wkSheet.Range("A:B").EntireColumn.Insert

to:

wkSheet.Range("A:A,B:B").EntireColumn.Insert

 
Answer #11    Answered By: Eddie Austin     Answered On: Jan 07

Thanks a lot, your code  adds one column before A and one column before B, Its a
nice a code to have

 
Answer #12    Answered By: Antonio Dunn     Answered On: Jan 07

there is not .value case in text box

You can write

If text1.text="ASK" then
text2.text=text1.text
else
text2.text=""
endif

If TextBox1 = " ASK " Then
TextBox2.Value = " True "
Else
TextBox2.Value = " false  "
End If

 
Didn't find what you were looking for? Find more on TextBox1_KeyPress Or get search suggestion and latest updates.

Related Topics:




 
 
 
 

Related Post