Tampilkan postingan dengan label Visual Basic. Tampilkan semua postingan
Tampilkan postingan dengan label Visual Basic. Tampilkan semua postingan

How to: Export a DataReport to Microsoft Word (.doc)

| 0 comments

By John D. Conway

In this article we'll create a simple database in Microsoft Access and then create a user interface in Visual Basic 6.0.

Putting everything together should be relatively easy because we'll use Adodc Componenet to make the connection to our Database.
We'll then add a DataEnvironment and DataReport and within minutes we'll be able to export our DataReport to a Microsoft Word Document. (.doc)

Creating our Database in Microsoft Access:

Create a blank database in Microsoft Access and name the database: DataReport. Now create a table by going to: Create Table in Design View and enter the Field Name(s) and Data Type(s) as shown in the image below. Save the table and name it: Customers.

Microsoft Access Visual Basic 6 Database Download Tutorial

Now, open the Customers Table and fill in the information you see in the image below.

Customers Table Microsoft Access

Now let's move on to creating a user interface in Visual Basic 6.0. We're almost there. We"ll just place a few controls and in a short time we'll be able to Export our DataReport to a Microsoft Word. (.doc)

Creating our User Interface in Visual Basic 6.0

Open Visual Basic and choose: Standard EXE. Add a Adodc Component by going to Projects, Components and choose Microsoft ADO Data Control. Click Apply and then Close. You will now have a this Component in your ToolBox. Add 9 TextBox(s) named: Text1, Text2, Text3 and so on. Now add 9 Labels named: Label1, Label2, Label3 and so on. Change the Caption Property for each Label as shown in the image below. Add the Adodc Control from our ToolBox named: ADODC1. Add a CommandButton named: Command1. Change the Caption of the CommandButton1 to View Report. Now we just need to make the connection.

If you're wanting to Export a DataReport to Microsoft Word then I would guess that you already know the steps that need to be taken. This expanation will help those who are doing this for the first time or maybe have forgotten a step or two.

Right click ADODC1 control that we'd placed on Form1 and right click ADODC Properties. Choose: Use Connection String and left click Build. When prompted Choose Microsoft Jet 4.0 OLE DB Provider and click Next. Now, click the button to the right where you see 1. Select or enter a database name. Go to the location where you'd saved your database and double click. Check or Test your connection. If everything is on track you'll see a messagebox with the message "Test Connection Succeeded"-- Press OK to close the message and then press OK again.
Now, go to where you see RecordSource and left click. For the CommandType choose 2 - adCmdTable. Now go to Table or Stored Procedure Name and choose Customers (or whatever you'd named your Table) Now just click Apply and then click OK.

Now we'll set the DataSorce and DataField Properties to each Textbox that we'd place onto our Form1 earlier.

Click Text1 and then go to the Properties Window. Set the DataSource Property to ADODC1 and the DataField Property to CustID. (Note: All of the remaining TextBox(s) DataSource Properties will be set to ADODC1) Now go to Text2 and Set the DataSource Property. Set the DataField Property to LastName. Go to Text3 and Set the DataSource Property. Set the DataField Property to FirstName. Set the DataSource and DataField Properties for the remaining TextBox(s).

 Visual Baisc 6  Interface

Adding a DataEnvironment and DataReport

Go to Project and choose More ActiveX Designers. Now choose Data Environment. Once opened - right click on Connection1 and choose Properties. Choose Microsoft Jet 4.0 OLE DB. Now, click the button to the right where you see 1. Select or enter a database name. Go to the location where you'd saved your database and double click. Check or Test your connection. If everything is on track you'll see a messagebox with the message "Test Connection Succeeded". Click OK.
Right click on connection again but this time choose Add Command. Now right click on Command1 and click Properties. Set the DatabaseObject to Table and then set the ObjectName to Customers. Click Apply and then click OK.
The final result will look like the image below.

Visual Basic 6 Data Environment

We are now ready to add a DataReport.

Go to Project and Choose Add Data Report. Adjust the size of the DataEnvironment and DataReport to resemble the image below.
Click the DataReport. Go to DataSource and change the property to DataEnvironment1 and then change the DataMember Property to Command1.
Now place your cursor on CustomerID - left click and hold-Now just drag over to Detail(Section1) You'll see two CustID. Choose the one on the left and drag it above to PageHeading(Section2) Repeat the same process to place LastName, FirstName, MI, Phone, Address, City, State and Zip.

Data Environment Data Report Visual Basic 6

Now double click the commandbutton that's on Form1 to bring up the Code Window. Enter DataReport1.Show in the Command1_Click event.The final result will resemble the image below.

Code to view Data Report

Start the project and then click the CommandButton to View Report. The report will look similar to the image below.
Notice the two buttons at the top left corner of your report. The button on the left will Print and the one on the right will allow us to Export. We'll use the Export feature in a moment.

You may need to adjust here and there to achieve the proper width of each column. This is where it will going to get a little tricky because we're only allowed a certain amount of space for the fields that we want to export.
What may look acceptable in the DataReport will not in Microsoft Word. So, I guess we can call this the experimental stage of the process. I've exported several DataReports this way and each time the results may vary. You'll get the hang of it once you've messed with it a time or two.
If you find yourself having trouble - there's a download at the bottom of this article that has everything you need.

Visual Basic 6 Data Report

Export a DataReport to Microsoft Word (.doc)

Start the project and click the View Report Button on the form. Click the Export button. Choose a location where you want to save the Documnent. Go to where you see File Name and type in the name DataReport.doc (Note: You must include .doc extension at the end of the File Name). Now go to Save as Type and choose TXT(*.txt) Now just click Save.

Go to where you'd saved the DataReport and double click to open. You will get a prompt that states "Microsoft Word can't import the specified format. The feature is not currently installed. Would you like to install it now?" Choose NO. The DataReport will now open in Microsoft Word. If the Report in Microsoft Word doesnt resemble the image below - Go to File ( In Microsoft Word) and then down to Page Setup...Go to PaperSize, choose LandScape and press OK. The report will adjust. If this doesnt fit all the fields the yoy will either have to - 1. Go back to the DataReport and make some adjustments, or 2. Go back to your DataBase and shorten the Field Names.

If the Report looks like you want it too and to avoid seeing the message that we encountered when we first opened MS Word to view the report - Go to file and choose Save As...Go to Save As Type and choose Word Document.

Visual Basic 6 Data Report Microsoft Word

Download the project that accompanies this article

Source Code


Option Explicit

'view datareport
Private Sub Command1_Click()
DataReport1.Show
End Sub
http://home.comcast.net/~conwayjd/INDEX.HTML

Creating Applications for Handheld Devices Using eMbedded Visual Basic

| 0 comments

Introduction

This basic tutorial explains how developers with a basic knowledge of Visual Basic 6 can adapt their skills to develop applications for handheld devices which run the Pocket PC 2002 or 2003 Operating System (O/S).

Introduction – eMbedded Visual Basic (eVB)

Although there is a selection of tools available which facilitate the design of software for embedded devices, eVB is a good place to start as the syntax is not alien to developers familiar with Visual Basic.

Nowadays a large majority of programmers are migrating to the .Net framework however, for those of you who, like myself, are old fashioned and feel comfortable with VB6 so think “Why bother changing?”, eVB will prove to be an easy to use tool for creating software for handheld devices.

eVB 3.0 is available as a free download from Microsoft’s Web Site, however eVB is only supported by the PocketPC (PPC) 2002 OS and the majority of modern hand-held devices are running PPC 2003. This tutorial will explain what to do in order to start using your existing VB knowledge to develop software for mobile devices.

Installing eVB

eVB is available as a free download for those running a genuine copy of Microsoft Windows, simply download the installation program (210MB). The product key for this edition is TRT7H-KD36T-FRH8D-6QH8P-VFJHQ. This freeware version of eVB is designed to run on the PPC 2002 Operating System (O/S), the SDK for this version is available here.

For those running PPC 2003, (this can be checked by viewing the “Version” option in the setup menu on the PDA) the Software Development Kit (SDK) should be downloaded from here. In addition to this SDK, the relevant run-time for 2003 must be downloaded.

In order to use this run-time, download the cabinet file to the Desktop, drag and drop it onto the Home directory of the mobile device, at this point a message will inform the user that 2002 run-times are already installed, and do they wish to proceed?, clicking “yes” will install the relevant run-times.

Other Options

Future versions of the PPC O/S will not support applications developed using eVB causing many developers to migrate to the .Net framework, using eVB only to maintain existing applications. In circumstances whereby Microsoft Visual Studio is not available, the other option is to develop applications using eMbedded Visual C++ v4.0, again, this is available as a free download for those running a genuine version of Windows.

In order to start using eVC++ it is necessary to download additional service packs. Although there are four service packs available, the two necessary ones are SP2 and SP4.

Moving From Visual Basic To The VB.net Shoppingcart

| 0 comments

The introduction of the VB.net shoppingcart caused a chasm to form among developers. This new computer language differed in many ways from the Visual Basic language that came before it. Like with all changes in any aspect of society, some people were very receptive to the new language and others wanted to hang on to the way that things once were. Since its initial release, the new VB.net language has been improved upon and more people are finding it to be an adequate developers’ language. However, not everyone has had an easy time making the switch.

When the VB.net shopping cart was first released, debate sprung up as to whether this was simply a new version of the old Visual Basic language or whether it should be considered an entirely separate product. While the basic idea of the language was the same, the implementation of it was very different. This is comparable to written languages, which use the same alphabet; the letters are the same but that doesn’t mean that someone whose primary language is Spanish will be able to read a document written in English.

The changes that were made in the new developers’ language essentially altered many of the interface features that existed in previous versions. People who like the new VB.net shoppingcart believe that these changes allow for a more open approach to new development. However, those who weren’t happy with the change felt that the new language was more difficult to work with and that the cost of learning and implementing the new system would be too high. Nevertheless, the new system has prevailed, albeit with some modifications.

For developers who are just starting to get used to VB.net, there are tools available to make it easier to make the switch. Microsoft’s VB.net website contains a learning center which provides information necessary to assist developers in understanding this new language. It has online papers and videos which break down the changes that occurred between the old Visual Basic and the new language. It also provides text and video data to assist with learning this new language whether you are a developer used to Visual Basic or a brand new developer.

In addition to the learning center, there are numerous tutorials available online. Microsoft as well as others have created these tutorials to make it easy to not only learn the general language but also to learn how to take individual actions on this new type of system. For example, someone who was designing a general VB.net e-commerce storefront but who didn’t know what steps to take to add the VB.net shoppingcart could hunt down an online tutorial and learn what needed to be done to add that cart.

Of course, not everyone is going to find that this language makes sense to them. There remain other languages out there that developers can work with. Some find that the open source versions of VB.net are easier to begin working with and provide more flexibility in creating new products. This may be particularly true of software developers who are working with the system and trying to create something that isn’t yet on the market. Other developers find that an entirely different computer language is the right course for them and may switch to working with non-Microsoft platforms to further their work.

The VB.net shoppingcart language seems to be something that is here to stay, at least for the time being. As more developers get accustomed to using this language, a more widespread appreciation of it may be seen. Inevitably, this system will be replaced by something else since the language of computers is always evolving.

Permanent Link: http://www.isnare.com/?aid=228317&ca=Computers+and+Technology

  © Metode Numerik Blogger Theme by Ourblogtemplates.com 2008

Back to TOP