Results 1 to 3 of 3

Thread: VBA Userform : Add value to textbox based on Mouse cursor

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2019
    Posts
    37

    VBA Userform : Add value to textbox based on Mouse cursor

    Hi Friends,



    This is my Userform. When ever i press the mathematical buttons values will come in the last of textbox (refer the image). I want VBA code where these values will come where the cursor is in the textbox.
    Example : I want "+" in between "(" and ")" . So basically i will add the curson between this and press the "+" button. But the values are coming in the last of this textbox.

    Someone please help me .

    Note : Refer the screenshot

    Thanks

  2. #2
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: VBA Userform : Add value to textbox based on Mouse cursor

    I don't see an image, perhaps because my work is filtering out images.
    I also don't see your code.

    But it sounds like you just need to use the SelText property, to put the text in at the cursor position (or in place of selected text if any is selected).
    Code:
    Private Sub Command1_Click()
      Text1.SelText = "+"
    End Sub

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2019
    Posts
    37

    Re: VBA Userform : Add value to textbox based on Mouse cursor

    WoW. Thanks alot.

    I was using Text1.Text instead of Text1.SelText .

Tags for this Thread

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