# Simple way to duplicate vba's InputBox, Msgbox?

**URL:** <https://www.ruby-forum.com/t/simple-way-to-duplicate-vbas-inputbox-msgbox/153566>\
**Category:** Ruby\
**Created:** [November 18, 2008, 9:20pm UTC](https://www.ruby-forum.com/t/simple-way-to-duplicate-vbas-inputbox-msgbox/153566 "2008-11-18T21:20:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![phil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e95f7d/32.png) [@phil](https://www.ruby-forum.com/u/phil)\
**Post date:** [November 18, 2008, 9:20pm UTC](https://www.ruby-forum.com/t/simple-way-to-duplicate-vbas-inputbox-msgbox/153566/1 "2008-11-18T21:20:54Z")

</div>

I’ve always used VBScript to write the simple scripts I  
occasionally need. But now that I’ve learned a tiny bit of  
ruby, I don’t want to use vbscript anymore!

Unfortunately for me, ruby has nothing like InputBox() and Msgbox().  
While I’m comfortable with the command prompt and often prefer  
it, sometimes its just more convenient to run scripts directly  
from windows.

As I’ll probably never need any more “GUI capabilities” than  
those two statements provide, it seems like fxruby, ruby tk,  
etc. is overkill for my simple needs.

I did run across “Ruby & Excel: The InputBox Hack” but of  
course it’s slow and at least for me, the prompt is not  
“active” (you have to Alt-tab to get to it)

Any comments or suggestions would be appreciated.

---

<div class="post-metadata">

**Author:** ![phil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e95f7d/32.png) [@phil](https://www.ruby-forum.com/u/phil)\
**Post date:** [November 18, 2008, 9:49pm UTC](https://www.ruby-forum.com/t/simple-way-to-duplicate-vbas-inputbox-msgbox/153566/2 "2008-11-18T21:49:17Z")

</div>

[www.shoooes.net](http://www.shoooes.net)  
You can get a simple window with inputbox like this:

Shoes.app :width =\> 220, :height =\> 100 do

para “Type some text:”

edit\_line(:width =\> 200).change { |el|  
alert el.text  
}

end

On 18.11.2008, at 20:16 , Phil wrote:

> those two statements provide, it seems like fxruby, ruby tk,  
> etc. is overkill for my simple needs.
> 
> I did run across “Ruby & Excel: The InputBox Hack” but of  
> course it’s slow and at least for me, the prompt is not  
> “active” (you have to Alt-tab to get to it)
> 
> Any comments or suggestions would be appreciated.

einarmagnus

---

<div class="post-metadata">

**Author:** ![phil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e95f7d/32.png) [@phil](https://www.ruby-forum.com/u/phil)\
**Post date:** [November 18, 2008, 9:50pm UTC](https://www.ruby-forum.com/t/simple-way-to-duplicate-vbas-inputbox-msgbox/153566/3 "2008-11-18T21:50:28Z")

</div>

On Nov 18, 3:14 pm, “Phil” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’ve always used VBScript to write the simple scripts I  
> occasionally need. But now that I’ve learned a tiny bit of  
> ruby, I don’t want to use vbscript anymore!
> 
> Unfortunately for me, ruby has nothing like InputBox() and Msgbox().

Shoes ([http://shoooes.net/](http://shoooes.net/)) is a simple GUI toolkit and probably what  
you’re looking for. Sample:

if confirm(“Do Something?”)  
do\_it  
else  
do\_something\_else  
end

– Mark.

---

<div class="post-metadata">

**Author:** ![phil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e95f7d/32.png) [@phil](https://www.ruby-forum.com/u/phil)\
**Post date:** [November 19, 2008, 3:30am UTC](https://www.ruby-forum.com/t/simple-way-to-duplicate-vbas-inputbox-msgbox/153566/4 "2008-11-19T03:30:52Z")

</div>

Phil wrote:

> Unfortunately for me, ruby has nothing like InputBox() and Msgbox().

You can display a MessageBox by via the Win32API:

> **[Displaying a MessageBox Using the Windows API](http://rubyonwindows.blogspot.com/2007/06/displaying-messagebox-using-windows-api.html)**
>
> Sometimes the only user interface you need is a message box. Maybe you just need to alert the user to the completion of a process; or maybe ...

The result is very similar to VB’s MsgBox function.

David

> **[Ruby on Windows](http://rubyonwindows.blogspot.com)**
>
> On using the Ruby programming language on the Microsoft Windows platform

---

<div class="post-metadata">

**Author:** ![phil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e95f7d/32.png) [@phil](https://www.ruby-forum.com/u/phil)\
**Post date:** [November 19, 2008, 7:20am UTC](https://www.ruby-forum.com/t/simple-way-to-duplicate-vbas-inputbox-msgbox/153566/5 "2008-11-19T07:20:36Z")

</div>

I now have a simple message\_box “function”

Shoes looks very interesting, and so easy…  
(at least to get a few trivial scripts working)

And i look forward to checking out zerenity and rdialog.

– thanks to all!
