Results 1 to 9 of 9

Thread: change spinbutton value after textbox event [RESOLVED]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2004
    Location
    Lucenec, Slovakia
    Posts
    154

    Resolved change spinbutton value after textbox event [RESOLVED]

    Hi guys,

    I have probably very simple problem. I would like to set spinbutton value equal to textbox. I am using the following code:

    VB Code:
    1. Private Sub TextBox3_Click()
    2. UserForm1.SpinButton2.Value = UserForm1.TextBox3.Value
    3. End Sub

    Can anybody help me, what I did wrong?

    Thanks.

    Boris
    Last edited by bolcskei; Mar 20th, 2006 at 06:32 AM. Reason: [RESOLVED]

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: change spinbutton value after textbox event

    Which Office app are you using? Which version?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2004
    Location
    Lucenec, Slovakia
    Posts
    154

    Re: change spinbutton value after textbox event

    Quote Originally Posted by RobDog888
    Which Office app are you using? Which version?
    I am sorry. It is in Excel and I have VBA.

  4. #4
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: change spinbutton value after textbox event

    Open Excel, Help, About MSExcel, which version

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: change spinbutton value after textbox event

    You have it backwards. You are trying to get the spinbutton to increment or decrement the value in the textbox?
    VB Code:
    1. Private Sub SpinButton1_Change()
    2.     UserForm1.TextBox1.Value = UserForm1.SpinButton1.Value
    3. End Sub
    Moved
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Nov 2004
    Location
    Lucenec, Slovakia
    Posts
    154

    Re: change spinbutton value after textbox event

    Quote Originally Posted by RobDog888
    You have it backwards. You are trying to get the spinbutton to increment or decrement the value in the textbox?
    VB Code:
    1. Private Sub SpinButton1_Change()
    2.     UserForm1.TextBox1.Value = UserForm1.SpinButton1.Value
    3. End Sub
    Moved
    I have MS Office XP.

    "Showing" spinbutton value in textbox I have done. It works fine. But I would like to do a opposite procedure. To set the value of spinbutton based on the value of textbox. Now I did an idea, maybe I have to convert textbox value to number.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Nov 2004
    Location
    Lucenec, Slovakia
    Posts
    154

    Re: change spinbutton value after textbox event

    Quote Originally Posted by RobDog888
    You have it backwards. You are trying to get the spinbutton to increment or decrement the value in the textbox?
    VB Code:
    1. Private Sub SpinButton1_Change()
    2.     UserForm1.TextBox1.Value = UserForm1.SpinButton1.Value
    3. End Sub
    Moved
    I did a mistake. Textbox do not have click event.

  8. #8
    Frenzied Member zaza's Avatar
    Join Date
    Apr 2001
    Location
    Borneo Rainforest Habits: Scratching
    Posts
    1,486

    Re: change spinbutton value after textbox event [RESOLVED]

    Incidentally, did you know that you can use the LinkedCell property of the spin button to link it to the value of a cell.
    If you didn't want to use a textbox, that is. I hardly ever use textboxes in Excel, because using a cell is so much more flexible.

    zaza
    I use VB 6, VB.Net 2003 and Office 2010



    Code:
    Excel Graphing | Excel Timer | Excel Tips and Tricks | Add controls in Office | Data tables in Excel | Gaussian random number distribution (VB6/VBA,VB.Net) | Coordinates, Vectors and 3D volumes

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Nov 2004
    Location
    Lucenec, Slovakia
    Posts
    154

    Re: change spinbutton value after textbox event [RESOLVED]

    Quote Originally Posted by zaza
    Incidentally, did you know that you can use the LinkedCell property of the spin button to link it to the value of a cell.
    If you didn't want to use a textbox, that is. I hardly ever use textboxes in Excel, because using a cell is so much more flexible.

    zaza
    I did not know that. I do not like to use linked cell, because I like to prepare macros independent to opened file. Of course the linked cell I use with controls in Excel.
    But, thanks for an idea.
    Boris

    the mistake must be between the keyboard and the chair!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width