![]() |
Seeing value in textbox
I am running a VB script and want to have an amount entered in an input box
for display in a textbox. The value is only being displayed after all the code is executed and not after the Ok button of the input box is selected as I would wish to happen. These controls are on a worksheet. What can I do? David |
Seeing value in textbox
On Mar 22, 8:54 pm, "willing2learn" <u32721@uwe wrote:
I am running a VB script and want to have an amount entered in an input box for display in a textbox. The value is only being displayed after all the code is executed and not after the Ok button of the input box is selected as I would wish to happen. These controls are on a worksheet. What can I do? David David, If you are looking for the InputBox value to appear in the text box right after the InputBox "OK" button is pressed, then place the line of code in your program that takes the InputBox variable (and subsequently writes that variable to the text box) right after the InputBox line of code. From your problem description, that's the best answer I can give you. If you need something more specific, post some code or write a problem description that is more detailed. Matt |
Seeing value in textbox
matt wrote:
I am running a VB script and want to have an amount entered in an input box for display in a textbox. The value is only being displayed after all the code is executed and not after the Ok button of the input box is selected as I would wish to happen. These controls are on a worksheet. What can I do? David David, If you are looking for the InputBox value to appear in the text box right after the InputBox "OK" button is pressed, then place the line of code in your program that takes the InputBox variable (and subsequently writes that variable to the text box) right after the InputBox line of code. From your problem description, that's the best answer I can give you. If you need something more specific, post some code or write a problem description that is more detailed. Matt Hi Matt That's just what I am doing but I am really at a loss as to why my textbox is not displaying the vale. Here is some of the code. Dim Value1, Value2 Value1 = Application.InputBox(prompt:="Enter Deductions Amount", Type:=1) If Value1 = False Then End Else Worksheets("Cover").TextBox3.Value = Value1 End If Value2 = Application.InputBox(prompt:="Enter Net Cheques Amount", Type:=1) If Value2 = False Then End Else Worksheets("Cover").TextBox4.Value = Value2 End If -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200703/1 |
Seeing value in textbox
On Mar 23, 3:43 am, "willing2learn via OfficeKB.com" <u32721@uwe
wrote: matt wrote: I am running a VB script and want to have an amount entered in an input box for display in a textbox. The value is only being displayed after all the code is executed and not after the Ok button of the input box is selected as I would wish to happen. These controls are on a worksheet. What can I do? David David, If you are looking for the InputBox value to appear in the text box right after the InputBox "OK" button is pressed, then place the line of code in your program that takes the InputBox variable (and subsequently writes that variable to the text box) right after the InputBox line of code. From your problem description, that's the best answer I can give you. If you need something more specific, post some code or write a problem description that is more detailed. Matt Hi Matt That's just what I am doing but I am really at a loss as to why my textbox is not displaying the vale. Here is some of the code. Dim Value1, Value2 Value1 = Application.InputBox(prompt:="Enter Deductions Amount", Type:=1) If Value1 = False Then End Else Worksheets("Cover").TextBox3.Value = Value1 End If Value2 = Application.InputBox(prompt:="Enter Net Cheques Amount", Type:=1) If Value2 = False Then End Else Worksheets("Cover").TextBox4.Value = Value2 End If -- Message posted via OfficeKB.comhttp://www.officekb.com/Uwe/Forums.aspx/excel-programming/200703/1- Hide quoted text - - Show quoted text - Try this: Worksheets("Cover").Shapes("Text Box 1").Select Selection.Characters.Text = Value1 It should do the job. Matt |
Seeing value in textbox
matt wrote:
On Mar 23, 3:58 pm, "willing2learn via OfficeKB.com" <u32721@uwe wrote: On Mar 23, 3:43 am, "willing2learn via OfficeKB.com" <u32721@uwe wrote: [quoted text clipped - 20 lines] - Show quoted text - I'm not sure why you are getting the run-time error. Here's another swing at it: Worksheets("Cover").Shapes("Text Box 1").TextFrame.Characters.Text = Value1 Maybe this will help, maybe it won't. When I run the code with my previous post as well as the above line, they both work equally as well. I'm a bit baffled. Matt Hi Matt Is there any particular event from which you are running your code? Mine is in a procedure which is part of the entire script. How are you testing this? If I have a few lines of code then it would seen fine, but because my routines run for almost a minute my textbox values only appear after all the code has finish executing. -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200703/1 |
Seeing value in textbox
On Mar 24, 5:38 am, "willing2learn via OfficeKB.com" <u32721@uwe
wrote: matt wrote: On Mar 23, 3:58 pm, "willing2learn via OfficeKB.com" <u32721@uwe wrote: On Mar 23, 3:43 am, "willing2learn via OfficeKB.com" <u32721@uwe wrote: [quoted text clipped - 20 lines] - Show quoted text - I'm not sure why you are getting the run-time error. Here's another swing at it: Worksheets("Cover").Shapes("Text Box 1").TextFrame.Characters.Text = Value1 Maybe this will help, maybe it won't. When I run the code with my previous post as well as the above line, they both work equally as well. I'm a bit baffled. Matt Hi Matt Is there any particular event from which you are running your code? Mine is in a procedure which is part of the entire script. How are you testing this? If I have a few lines of code then it would seen fine, but because my routines run for almost a minute my textbox values only appear after all the code has finish executing. -- Message posted via OfficeKB.comhttp://www.officekb.com/Uwe/Forums.aspx/excel-programming/200703/1- Hide quoted text - - Show quoted text - I'm testing my code by simply drawing 2 text boxes into Excel and then running the code through in a module. I copied your code into my module and tested it with the 2 text boxes I placed in the worksheet. The only other thing that I can think for you to do is to write a For...Each loop for the shape names and verify that you are indeed referring to "Text Box 1" and "Text Box 2". Matt Sub shapesNames() Dim a As Variant For Each a In ActiveSheet.Shapes Debug.Print a.Name Next End Sub |
Seeing value in textbox
To add onto what Matt wrote, I would recommend breaking your code into
smaller sub procedures, with called from the event procedure that you're working with. It makes it much easier to test and logically organize your program. Plus, you can write small test functions for each sub to run independently, saving you a lot of debugging time in the long run. - Nick Hebb |
All times are GMT +1. The time now is 06:16 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com