# Get\_value problems and more, beginner

**URL:** <https://www.ruby-forum.com/t/get-value-problems-and-more-beginner/176379>\
**Category:** wxRuby\
**Created:** [September 29, 2009, 9:18pm UTC](https://www.ruby-forum.com/t/get-value-problems-and-more-beginner/176379 "2009-09-29T21:18:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexanderl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f0a364/32.png) [@alexanderl](https://www.ruby-forum.com/u/alexanderl)\
**Post date:** [September 29, 2009, 9:18pm UTC](https://www.ruby-forum.com/t/get-value-problems-and-more-beginner/176379/1 "2009-09-29T21:18:14Z")

</div>

Hello! I have just got in to WxRuby and i already enjoy it alot. But i  
have some problem. I am doing a very simple port-scanner, very basic  
socket.

“TCPSocket.open(ipaddress.chop, port)” - Like that.

But now i want to do it graphical. So, my thought is the following. I  
have three fields, structured like this.  
[![](http://tinypic.com/images/goodbye.jpg) ](http://tinypic.com/images/goodbye.jpg)  
Then a 4th field to the right, where the output should be. But… How can  
i take the values from my three fields.

> Where i enter IP  
> Start-port-range  
> End-port-range

Save them in variables, then do the portscan with them? I know that  
“get\_value” exists. But i don’t really know how to apply it.

So. Short and consist.  
I have 3 fields where i ask for user input, i want to save the values in  
these fields in variables, then i will scan the target, and the output  
from the scan shall happen in the “large” field.

Is that possible? 😕  
/Alexander

---

<div class="post-metadata">

**Author:** ![alexanderl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f0a364/32.png) [@alexanderl](https://www.ruby-forum.com/u/alexanderl)\
**Post date:** [September 29, 2009, 11:48pm UTC](https://www.ruby-forum.com/t/get-value-problems-and-more-beginner/176379/2 "2009-09-29T23:48:33Z")

</div>

Hi Alexander,

Alexander L. wrote:

> So. Short and consist.  
> I have 3 fields where i ask for user input, i want to save the values in  
> these fields in variables, then i will scan the target, and the output  
> from the scan shall happen in the “large” field.
> 
> Is that possible? 😕

So long as you store a reference to the created TextCtrl field in a  
variable, you can get the value using ‘get\_value’

The code below will display a text field and a button. When clicked,  
the button uses the ‘get\_value’ method to retrieve the contents of the  
text field.

* * *

require ‘wx’

class MyFrame \< Wx::Frame  
def initialize  
super(nil, :title =\> “Controls”)

```
text_field = Wx::TextCtrl.new(self)
button = Wx::Button.new(self, :label => "Show Value")
evt_button(button) {p "Value: #{text_field.get_value}"}

main_sizer = Wx::BoxSizer.new Wx::VERTICAL
main_sizer.add text_field
main_sizer.add button
set_sizer main_sizer

```

end  
end

## Wx::App.run do MyFrame.new.show end

Does that help you move forward?

regards,

```
Peter.

```
