473,387 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Select Case

I have created a form with 2 combo boxes. The purpose of the form is to
export CR9 reports to selected types of formats (rpt, doc,xls, etc) and
choose the destination for the report (mail, file, etc.). What is the best
method to state if selectedindex 1 and selectedindex 2 are selected so that
then the export methods is carried out according to the users wishes.

Thanks in advance!

Using VB.Net 2003

Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click

Dim FileType As String
Select Case Me.cbFormat.SelectedIndex

Case 0 'PDF Format

FileType = ".pdf"

Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions

crDiskFileDestinationOptions.DiskFileName = ExportRptPath & "\" & subject &
FileType

Dim crExportOptions As ExportOptions = rpt.ExportOptions

With crExportOptions

..DestinationOptions = crDiskFileDestinationOptions

..ExportDestinationType = ExportDestinationType.DiskFile

..ExportFormatType = ExportFormatType.PortableDocFormat

End With

'execute conversion to PDF

Case 1

FileType = ".rpt"

Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions

crDiskFileDestinationOptions.DiskFileName = ExportRptPath & "\" & subject &
FileType

Dim crExportOptions As ExportOptions = rpt.ExportOptions

With crExportOptions

..DestinationOptions = crDiskFileDestinationOptions

..ExportDestinationType = ExportDestinationType.DiskFile

..ExportFormatType = ExportFormatType.CrystalReport

End With

Case 2

FileType = ".xls"

Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions

Dim excelFormatOpts As New ExcelFormatOptions

Dim crExportOptions As ExportOptions = rpt.ExportOptions

'crDiskFileDestinationOptions.DiskFileName = "c:\winaeros\reports\test.xls"

crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile

crDiskFileDestinationOptions.DiskFileName = ExportRptPath & "\" & subject &
FileType

crExportOptions.DestinationOptions = crDiskFileDestinationOptions

crExportOptions.ExportFormatType = ExportFormatType.Excel

excelFormatOpts.ExcelTabHasColumnHeadings = True

crExportOptions.FormatOptions = excelFormatOpts

Case 3

FileType = ".xls"

Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions

crDiskFileDestinationOptions.DiskFileName = ExportRptPath & "\" & subject &
FileType

Dim crExportOptions As ExportOptions = rpt.ExportOptions

Dim excelFormatOpts As New ExcelFormatOptions

With crExportOptions

..DestinationOptions = crDiskFileDestinationOptions

..ExportDestinationType = ExportDestinationType.DiskFile

..ExportFormatType = ExportFormatType.ExcelRecord

End With

excelFormatOpts.ExcelTabHasColumnHeadings = False

crExportOptions.FormatOptions = excelFormatOpts

Case 4

FileType = ".doc"

Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions

crDiskFileDestinationOptions.DiskFileName = ExportRptPath & "\" & subject &
FileType

Dim crExportOptions As ExportOptions = rpt.ExportOptions

With crExportOptions

..DestinationOptions = crDiskFileDestinationOptions

..ExportDestinationType = ExportDestinationType.DiskFile

..ExportFormatType = ExportFormatType.WordForWindows

End With

End Select

Select Case Me.cbDestination.SelectedIndex

' Case 0 'Application

'Case 1 'Disk File

'' Allow the user to save a file.

'Dim ofd As New SaveFileDialog

'Dim dr As DialogResult

'dr = ofd.ShowDialog(Me)

'If dr <> dr.Cancel Then

'Else

'MsgBox(ofd.FileName)

'End If

'Case 2 'Exchange Folder

Case 3 'Outlook

'Mail Procedure

Dim olApp As Outlook.Application

Dim olMailMessage As Outlook.MailItem

olApp = New Outlook.Application

olMailMessage = olApp.CreateItem(Outlook.OlItemType.olMailItem)

olMailMessage.Attachments.Add(ExportRptPath & "\" & subject & FileType)

olMailMessage.Subject = subject

olMailMessage.Display()

olMailMessage = Nothing

End Select

rpt.Export()

Me.Close()

End Sub
Nov 22 '05 #1
0 3092

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mohammed Mazid | last post by:
Hi folks! Can anyone please help me with this? I am developing a Quiz program but I am stuck with "multiple answers". Basically I need some sort of code that would select multiple answers...
17
by: Newbie | last post by:
Dear friends, I am having a hard time understanding how to use a SELECT CASE in ASP. I have used it in VB but never in ASP scripting. Scenerio: I have 2 textboxes on a form that I have to...
9
by: Kevin | last post by:
Hi, I am getting a syntax error Microsoft VBScript compilation error '800a03ea' Syntax error On the code below. The error references the "End Select" line Can anyone help me with what I am...
8
by: Penny | last post by:
Hi all, My browser throws this Select Case block back at me pointing out a syntax error on the line: 'Case < 251', between the word 'Case' and the '<' symbol. *************************** ...
10
by: MLH | last post by:
Suppose the following... Dim A as Date A=#7/24/2005# I wish to compare value of A against 2 other values: 1) 8/1/2005 2) 9/1/2005 Which is better and why... First:
7
by: Lauren Quantrell | last post by:
Is there any speed/resource advantage/disadvantage in using Select Case x Case 1 Case 2 etc. many more cases... End Select VS.
3
by: Rob Meade | last post by:
Ok - I *think* this is only different in .net 2.0 - as I've not had any problems in the past, but then maybe I've not tried it... I have a value being read from an xml file where the value maybe...
8
by: | last post by:
Hello, This is gonna sound real daft, but how do I test a Select Case statement for variants of a theme? Here's a snippet of my code... Select Case sUsr Case "Guest", "TsInternetUser",...
1
by: microsoft.public.dotnet.languages.vb | last post by:
Hi All, I wanted to know whether this is possible to use multiple variables to use in the select case statement such as follows: select case dWarrExpDateMonth, dRetailDateMonth case...
4
tjc0ol
by: tjc0ol | last post by:
Hi guys, I'm a newbie in php and I got error in my index.php which is: 1054 - Unknown column 'p.products_id' in 'on clause' select p.products_image, pd.products_name, p.products_id,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.