cancel
Showing results for 
Search instead for 
Did you mean: 

Using CLASS in VB.NET

leon_laikan
Participant
0 Kudos

Hi, everybody

I am developing an SDK application using VB.NET.

My first Screen is called "Selection Criteria" (a simplified picture is shown below)

If we press "OK", another form opens, with a few tabs (folders)

Which tab opens will depend on which Option buttons have been clicked.

Each folder is associated with a grid or a series of objects (Edit Texts, Combo Boxes etc)

Each folder is independent of the other folders. My application can be regarded as a number of applications put together under one roof for convenience, although they all use the parameters set in the Selection Criteria screen.

Which application is fired depends on which Option buttons are clicked on the Selection Criteria Screen.

I am writing my code in a single class, and I am rather concerned that my code is getting very long (now above 5000 lines)

My concerns are (1) readability (2) ease of maintenance (3) simplicity of code.

I wish to know if using CLASS can help me write more readable code.

Or is using MODULE more appropriate?

I never programmed with MULTIPLE CLASSES  before. I am reading as much as I can about CLASS.

Can I use a separate class to hold the code for each folder (Tab1, Tab2, Tab3, etc) ?

How can I program VB.NET so that when (say) if I click Option button 1 and Option button 2, this runs the code for Folder1?

Please offer some general advice or links to relevant sites to initiate me on the subject.

Thanks

Leon Lai

Accepted Solutions (1)

Accepted Solutions (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Leon,

If I am getting you correctly then I would suggest you to have a look at the Partial Class in C#.

Althogh I have never tried this as you want. I generally write everything in a single class for a single form.

Still you can have a look on the concept of the partial class.

Hope it helps.

Thanks & Regards

Ankit Chauhan

SAP Business One Global Support

leon_laikan
Participant
0 Kudos

Hi Ankit,

Thanks a lot for your reply.

I use VB.NET rather than C#. Nevertheless I will search for "Partial Class" as suggested

Let me rephrase my question:

My problem is that my code is becoming too long to read and understand.

I want to break it down into manageable parts (as my application is in fact a series of separate applications). Still I want all these different applications to be grouped under one roof, for user convenience..

How can I do that?

Should I use different CLASSES?

or Should I use different MODULES

or Should I use another technique? Which one?

Best Regards

Leon

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Leon,

You can search it on Google to find it in VB .Net.

Also as far as your question is concerned, you can try with the partial class.

Here is little about it:

It splits the definition of a class over two or more source files. You can create a class definition in multiple files but it will be compiled as one class.

Hope it helps.

Thanks & Regards

Ankit Chauhan

SAP Business One Global Support

leon_laikan
Participant
0 Kudos

Hi Ankit,

Thanks again.

I will do some more search.

Best Regards,

Leon

edy_simon
Active Contributor
0 Kudos

Hi Leon,

Theoretically you can use partial class.

But IMHO using partial class to hold each of the folder will make your code more difficult to read and debug.

I personally would opt for 1 class to represent 1 form.

Regards

Edy

leon_laikan
Participant
0 Kudos

Hi Edy,

Thanks a lot for your response.

I think I am opting for your suggestion.

I have made a new post on the forum. You may wish to have a look here:

Best Regards

Leon Lai

Answers (0)