Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

problem about textbox

  Asked By: Gene    Date: Dec 15    Category: MS Office    Views: 768
  

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


Any help would be appreciated.

Share: 

 

12 Answers Found

 
Answer #1    Answered By: Dennis Hayes     Answered On: Dec 15

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: Canan Kaya     Answered On: Dec 15

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: Steve Boyd     Answered On: Dec 15

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: Raul Clark     Answered On: Dec 15

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: Nixie Schmidt     Answered On: Dec 15

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: Isabelle Brown     Answered On: Dec 15

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

 
Answer #7    Answered By: Nagaraju Iyaner     Answered On: Dec 15

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: Tyrone Sanchez     Answered On: Dec 15

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: Jonathan Brown     Answered On: Dec 15

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: Husani Chalthoum     Answered On: Dec 15

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: Jared Adams     Answered On: Dec 15

our code  adds one column before A and one column before B, Its a
nice a code to have

 
Answer #12    Answered By: Tarrant Thompson     Answered On: Dec 15

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 problem about textbox Or get search suggestion and latest updates.




Tagged: