0

I had msg box in my Vb program like this

MsgBox("Record inserted successfully")

how to autoclick the ok button from code is there any way to do that in Visual Basic... i am very new to Visual Basic please help me

Surya Prakash Tumma
  • 2,153
  • 4
  • 27
  • 47
  • Possible duplicate of [Automatically close MsgBox in vbscript?](http://stackoverflow.com/q/14105157/113116). – Helen Jan 10 '13 at 08:22

2 Answers2

0

You could do this by obtaining the MessageBox's hWnd and then sending it a message to simulate the Ok click. However, this is very complicated relative to the desired outcome, if it's even possible that way.

I would suggest creating your own form that mimics the messagebox and expose a public method that will allow you to control it.

David Osborne
  • 6,436
  • 1
  • 21
  • 35
0

There is a very long way to do that. You have to call a lot of APIs etc... I recommend you to create a dialog form having a label with text "Record inserted successfully" and a button with text "OK". By doing this you will have easier control over it.

You can show the dialog like this:

    Dim newdialog As New Dialog1
    Me.ShowDialog(newdialog)

And simulate the button press, which means closing the dialog:

    newdialog.Close()
gunakkoc
  • 1,069
  • 11
  • 30