❔ How to Initialize different forms using same piece of code

I have this piece of code and i want to use it for different forms. In this case i can't initialize the form directly using its name like `customForm frm = new customForm();' and i tried using the 'Form' class which is more general. Problem is that initializing forms using the 'Form' class does not work properly. How can i make this function work with different classes?
8 Replies
canton7
canton72y ago
You probably want Form form = new CustomForm()?
Diesel Geezer
Diesel GeezerOP2y ago
No that won't work. I want this function to work with multiple forms, not just one, like customForm
canton7
canton72y ago
Why won't that work exactly? I'm a little confused by the code in your question. I'm not sure what it's trying to do -- is it trying to show a form, or create one? If it's trying to create one, why are you passing one in?
Diesel Geezer
Diesel GeezerOP2y ago
Its trying to create form and if it already exists, just show it. I am passing the form that i want to create/show
HimmDawg
HimmDawg2y ago
So basic question: You only want one placeholder for a form which can be filled with any of those 5 forms? Or do you want to be able to hold 5 placeholders, one for each form and check against those?
Diesel Geezer
Diesel GeezerOP2y ago
The first one
HimmDawg
HimmDawg2y ago
Well you cannot overwrite frm in your method of course. You need to have some placeholder outside of the method to preserve a form
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server