Results 1 to 10 of 10

Thread: Send a message with a command button

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    219

    Send a message with a command button

    how can i send something through a txtbox with a command button? example if i click cmdbutton1 it will send a message through the txtbox without me typing it??I would appreciate the help thank you

  2. #2
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Send a message with a command button

    VB Code:
    1. Private Sub Command1_Click()
    2.     Text1.SetFocus
    3.    
    4.     'text1.SelStart = len(text1.Text)   'To start typing at the end
    5.     'text1.text = ""    'To remove old text before writing
    6.    
    7.     SendKeys "hello", True
    8. End Sub

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

    Re: Send a message with a command button

    Where do you want to send it? another programs text box or are you talking about using NET SEND service?
    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

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    219

    Re: Send a message with a command button

    andrew the problem with your code is that it writes it but doesnt send it.. roddog im not quite sure what you mean by NET SEND services

  5. #5
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Send a message with a command button

    do you mean

    text1.text = "hello"

    if not you could use sendmessage with WM_SETTEXT

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    219

    Re: Send a message with a command button

    again all text.text= "hello" does is write it but doesnt send it i would like it to send it and could you explain what WM_SETTEXT is?

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

    Re: Send a message with a command button

    NET SEND is where you can send messages to other systems on your network.

    SendKeys only send the keys to the window that has the focus. So if you want it sent to a unfocused window it will either need to be activated first or use a more reliable method.
    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

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    219

    Re: Send a message with a command button

    so NET SEND could be used in like chat programms because its sending the text to other people??

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

    Re: Send a message with a command button

    Yes, but only on your intranet and not internet. Most systems have the Messenger service disabled so it doesnt work since last year or so we had people trying to do spamming with the messenger service.
    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

  10. #10
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Send a message with a command button

    You can do this,

    VB Code:
    1. Private Const WM_SETTEXT    As Long = &HC
    2.  
    3. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, _
    4.                                                                       ByVal lpWindowName As String) As Long
    5. Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, _
    6.                                                                           ByVal hWnd2 As Long, _
    7.                                                                           ByVal lpsz1 As String, _
    8.                                                                           ByVal lpsz2 As String) As Long
    9. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
    10.                                                                         ByVal wMsg As Long, _
    11.                                                                         ByVal wParam As Long, _
    12.                                                                         lParam As Any) As Long
    13.  
    14. Private Sub Form_Load()
    15.  
    16. Dim lng1 As Long
    17. Dim lng2 As Long
    18.  
    19.     lng1 = FindWindow("ThunderFormDC", "form1")
    20.     lng2 = FindWindowEx(lng1, 0&, "ThunderTextBox", "Text1")
    21.     SendMessage lng2, WM_SETTEXT, 0&, ByVal "hello"
    22.  
    23. End Sub

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