How to create apps for Excel VBA and VB.NET with almost no VBA code changing

vb vs.vba This is a topic that many people are looking for. bluevelvetrestaurant.com is a channel providing useful information about learning, life, digital marketing and online courses …. it will help you have an overview and solid multi-faceted knowledge . Today, bluevelvetrestaurant.com would like to introduce to you How to create apps for Excel VBA and VB.NET with almost no VBA code changing. Following along are instructions in the video below:

“And welcome back in this section. I will show you how you can transfer your your cold from excel vba to for example vbnet or. C. Sharp i will use this first.

Lesson a vbnet because it is practically similar as vba code and now if you want to create your standalone applications that are not bound to excel to office you can do it with vbnet or you can create your forms in. Excel vba and then simply transfer it to vbnet or c sharp if you don t have visual studio on your machine. You can download a totally free visual studio community edition to do so you simply go to google and typed visual studio community and it will bring you to the free ide visual studio community you can download and install it on your computer on your machine. When you are done you can simply go and start your visual studio 2017 let s run it and now that we are in the visual studio.

You can simply go to file new project and in this new project window. You can simply go to installed go to the visual basic and we will use our windows classic desktop and. Here we can select windows. Forms app we will name it vba to vbnet vba to vbnet you can click on ok and the project with a bun simple form has opened we will save our project go to save.

Wall we will name it we bed to vbnet location i will choose my. Desktop i will create a new folder vba to vbnet. Ok. Select folder and click save.

Now. First thing. If you remember when we have created when we have first opened our excel development. We needed to add a reference to a butyl forms object control to do so here in vbnet or in visual studio.

2017. You simply go to the references right click on the mouse and to the add references and if you have installed on your machine with 12 forms framework. When you type in search with. 12 it should pop.

Up we will select this with 12 form 20..


Tick on this check box and click ok. Let s add a button to our form and on the right here. We will change the text to twitter form designer. If you double click.

It will open a code editor and it will place us to the subroutine or to the event button one click and to see how similar this is to vba. I will open our project that we have created in the vba or in excel vba go to developer go to visual basic main menu. I will simply copy this line of code public with events. We have one as with 12 form.

2. With 12 form copy and place it here. After the public class formed one and this will give us if you remember this with events. If i delete it we will not have any events from little form control.

But if we again put it here we will have the events that we talk for control fires that we also have in our vba. So now you can see this line of code is similar to one that we have in our vba code. Let s go and see what is the next next. We need to set we need to initialize our little phone control in some kind of user form initialization event.

I will copy this but because if we go here and if we select form events and take a look at the form events here in visual studio 2017 or in visual basicnet. We don t have a user form initialization event. We have for example a load event and we can put this code in the load event this load event will fire only once when the form is loading. And as you can see the visual.

Basic editor. Or the visual studio is sent to us that let. And said assignment statements are no longer supported so we will remove this now let s go to the next line next line. We need to tell the ritual form control or our instance of it of alt control.

What database type..


We want to use i will also copy this comment copy and paste it let s have some space and paste. It here next line will also copy this from our vba copy and in this line. We are telling our application where our literal form definition file is located because this workbook is specific only to excel. We cannot use this here.

So for now. I will put in the full path to our definition file to do so i will go to our project folder right click on our definition file properties and i will copy this location right click copy ok ok and i will place it i will remove this and i will place it here before this backslash now we have the full path to our definition file. We have created a new instance of our rita form control called vf. 1.

Then we have tell the widow for control or our instance of it upon control that we will use a database type that is number. 2. That we will use number two is quayle. Then we have told our instance of ritual form control that the v12 form definition file.

Is located located here the next line of code. We will copy from our vba is the connection string. I will copy all of this select. It ctrl c.

And i will paste it here before we leave the application before we close the application. We also need to make a cleanup to do so i will go and take a pic here in our vba code. So in your subroutine user for terminate. We have those two lines of code.

I will copy them both right click copy and because in vba dotnet. We don t have this event user form terminate. But if you go if you go to the form to the form 1 events and take a look we have an event called closing. This is before the form closes down.

We still have the time to cancel the closing..


We will put here our cleaning code paste. So before the forum closes down. We will close all the twelve forms. We will tell our instance of it or phone control to close all the two forms and also to disconnect the database and now that we have clean up in this subroutine or in this event.

We also need to add our action to our button one click our bottom and click if you click here on the design our button. One click is a little form designer open a veto from designers so here in this subroutine or in this event. We will simply copy the event that we have used in our eba code that opens our ripped well form designer simply go here and copy this line select. It copy and let s paste.

It here in our application should be ready to open a ritual form designer. Let s go and test. It first. We will save it and click on the start the form has loaded and if we click on veto form designer our veto form designer is opened and also our application has passed the properties to the veto form control that has passed this property to the widow form designer where our definition rita phone definition file is located what database type we want to use and the connection string okay now we know this works.

But let s go and add. A new button that will open a rito form go to the design click on the button in the tool box. And let s draw a new button let s go and look in our application in our vba to the main menu. The second button is product categories.

Okay we will call it product categories go click on the button and go to the text property of this button and change it to product categories. Okay and let s go and take a look what code is executed. When we press this button in our vba. This line of code.

Okay it will open a vf2 form let s copy it right mouse click copy and double click on these product categories here in the vbnet and paste. This code here let s save it and let s start it now that we have our form if we click on product categories. It started orbital form and we can add a new category and this form is connected to our shared hosting database on the internet on the server located in europe in amsterdam. If i can remember good.

Ok..


Let s add a new category get a. Very it s called category shared. Ok and the form works also here we can also go and add one more button click on button drop the button and we will name it just like it is in our vba products. Ok go back here click on the button and in the text property change.

It to products. We also need to add an action. What will the application do when we click on this product button. We will go to our vba code.

Once again double click on the products button and copy the code that we have here copy and paste. It here now let s save it and let s give it a try here s a form with off on designer. We have already tested product categories. Ok.

Let s see it once again this works and products here are our products. Now you can see it this is almost identical as the vba code. So when you are using retool forms with a mysql database you can create it in. Excel vba and then you can transfer it to vbnet.

This code is almost identical. There will be when we go and do some more complicated. Things it will maybe change a little between vba and vbnet. But not a lot so you can see you can use excel vba you can use also vbnet and also you can because if you can use it from vbnet.

You can also use it from c sharp with that in mind. I believe you we will see us in the next. ” ..

.

Thank you for watching all the articles on the topic How to create apps for Excel VBA and VB.NET with almost no VBA code changing. All shares of bluevelvetrestaurant.com are very good. We hope you are satisfied with the article. For any questions, please leave a comment below. Hopefully you guys support our website even more.
description:

tags:

Leave a Comment