How to get the control values from form to class

Hi Friends,

I am having a string control field in my form. I want to pass the value which is given in that control fields to class.

can anyone suggest?

How are you calling the class from that form? Please elaborate.

Is that string control a bound field?

Thanks for the reply Krnathi.

Is that string control a bound field?

No Krnathi. It just an unbound field for user entry which is created by me.

How are you calling the class from that form?
I am calling the class on the normal button click event.

Can you show your code in clicked method?

Have you tried using parm method?

void clicked()
{

ProductCallingExtends extend = ProductCallingExtends();
super();

extend.main();
}

The above is my clicked method. How can I pass the value? My control field name is “Name”.

Have you tried using parm method?

shall you give any example?

Please compile your code to find compilation errors. You forgot the ‘new’ keyword.

ProductCallingExtends extend = new ProductCallingExtends();

In general, if you want to pass something to an object, you call a method and pass the data through a parameter. Like this:

o.myMethod('data');

There is a common pattern for methods just getting and setting values: parm methods.

Therefore if you want to create an instance and pass some data to it, you can do this:

ProductCallingExtends extend = new ProductCallingExtends();
extend.parmSomeValue('xyz');

Note there is one more option - you could initialize the value directly in constructor:

ProductCallingExtends extend = new ProductCallingExtends('xyz');

To get the value from your unbound control, change its AutoDeclaration property to Yes. Then you can use the object in code. Like this:

str nameValue = Name.text();

Now we can put it all together:

ProductCallingExtends extend = new ProductCallingExtends();
extend.parmName(Name.text());

Hi Martin,

Please compile your code to find compilation errors. You forgot the ‘new’ keyword.
Thanks for this. At the same time, I am having a new keyword in my code. This is my mistake, when I have edited the code for showing to Kranthi, I missed that. I will correct it.

Thanks for giving this brief solution for me.

Main is a static method, (see the below example)

Args args = new Args();

args.parm(Name.text());
ProductCallingExtends::main(args);

Thank you very much Kranthi and Martin. That is worked for me.

Below is my code:

void clicked()
{
str name1;
ProductCallingExtends extend = new ProductCallingExtends();
super();
name1 = Name.text();
extend.gettingfromform(name1);
}

When your question gets answered, please don’t forget to verify answers. It will make clear that the thread doesn’t need attention anymore and others looking for answers will be able to find the easily.

Also, please use Insert > Insert code to paste source code. It preserves indentation, making code easier to read.

Ok, Martin. I got it.