|
If you're worried about the speed, you could use ngen[^] which compiles your application to processor specific code.
|
|
|
|
|
Partially true. It doesn't speed up your code though. All NGEN does is precompile everything all at once instead of waiting for the JIT to do the same thing on-the-fly.
|
|
|
|
|
Hi,
VB.NET is a compiled language, it is capable of offering adequate performance for normal jobs.
Other languages, even interpreted ones, could be capable of the same as long as they have native
libraries for the most challenging tasks. On the other hand a mediocre programmer will always be able to create a dog that performs terribly, whatever language he chooses.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Basically I have multiple Excel files and each file has four sheets. I am trying to print each work book to a separate PDF. The first work books converts to a PDF with no problem however on the second go-around PDFCreator hangs and only the last page of the second work book is saved as a PDF. I've been working on this nonstop for two days now and can't figure out what else to do. Below is the code (with comments) for the sub routine that is supposed to do the conversion. The lines between asterisks is where the code hangs. Thanks in advance. PS: Sorry for the long code.
With m_ExcelApp 'This is the Excel COM object
.Visible = False 'Ensure that all work is done in the background
pdfjob = New PDFCreator.clsPDFCreator 'The PDFCreator object is created
' If pdfjob.cStart("/NoProcessingAtStartup") = False Then
MsgBox("Can't initialize PDFCreator.", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Error!")
Exit Sub
End If
'/// This is opening up the Excel file one by one ///
For i As Integer = 0 To IntDistList.Count - 1
PSFileName = IntDistList(i).ToString.Insert(IntDistList(i).ToString.LastIndexOf("\"), "\Reports") & ".pdf"
workbook = .Workbooks.Open(IntDistList(i).ToString.Insert(IntDistList(i).ToString.LastIndexOf("\"), "\Reports") & ".xml")
sheet = .ActiveWorkbook.Sheets(2)
sheet.Activate()
sheet.PageSetup.PrintTitleRows = "$1:$9"
sheet = .ActiveWorkbook.Sheets(3)
sheet.Activate()
sheet.PageSetup.PrintTitleRows = "$1:$10"
.ActiveWorkbook.Save()
' div = PSFileName.Split("\")
sPDFName = div(div.GetUpperBound(0))
sPDFPath = PSFileName.Substring(0, PSFileName.LastIndexOf("\")) & "\"
'/// Set all default settings ///
With pdfjob
.cOption("UseAutoSave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cClearCache()
End With
'/// Print the file to PDF ///
lTtlSheets = .Sheets.Count
For lSheet = 1 To .Sheets.Count
If .Sheets(lSheet).usedrange IsNot Nothing Then
.Sheets(lSheet).printout(activeprinter:="PDFCreator")
Else
lTtlSheets -= 1
End If
Next
'/// Wait until all print job have entered the print queue ///
'*******************This is where the program hangs on the second go-around but works fine for the first file*****************
Do Until pdfjob.cCountOfPrintjobs = lTtlSheets
Thread.Sleep(30)
Loop
'************************************************
'/// Combine all PDFs into a single file and stop the printer ///
ChangeStatus("Combining Files")
With pdfjob
.cCombineAll()
.cPrinterStop = False
End With
'/// Wait until PDF creator is finished then release the objects ///
ChangeStatus("Finalizing File")
Do Until pdfjob.cCountOfPrintjobs = 0
Thread.Sleep(1000)
Loop
Thread.Sleep(2500)
ChangeStatus("Closing File")
.ActiveWorkbook.Close()
PSFileMerge.Add(PSFileName)
Next
ChangeStatus("Releasing Objects")
pdfjob.cClose()
pdfjob = Nothing
End With
|
|
|
|
|
|
I know...I know. I originally had this working perfectly with Adobe Acrobat but after I finished it that's when my company decided that they didn't want to get Acrobat for everyone so I'm trying to figure out a way around it using free PDF printers. If you know other way that'll work I would love to know since this is my last obstacle. I really can't wait till Adobe comes out with there finally PDF-XML standard and I can just go to that.
|
|
|
|
|
I really don't, but I feel your pain. We (at this company) are making an ESRP where excel is the engine, I've been designated the VBA guy. I've not opened VS in 3 months, sometimes I open it just to hope.
|
|
|
|
|
I think I would have an easier time if I was actually doing all of the work in Excel, but I'm using Interop because there is a bunch of pre & post processing I have to do on the data and files.
|
|
|
|
|
I finally figured it out. The line .cPrinterStop = False starts the printer drives to output the final PDF. What was happening is that unless you stop it again it will only output the last sheet. So after all the processing is done on one workbook you need to add .cPrinterStop = True so the printer will not output anything until all the intermediate PDFs are processed and and the printer is restarted by the .cPrinterStop = False on the next loop. Wish there had been better IntelliSense on this matter but it works now. What a headache.
|
|
|
|
|
Hello frnds,
Here is the issue.
My application should check whether or not the space provided for displaying a string (in different languages) is sufficient. I have Width and Height of the space provided in pixels and font type, font size of the string.
So how can i solve this? I can think of 2 ways.
1. Get width of each character and sum up to get the width needed in pixels. For this i need to know width of each character in pixels? Is there a way i can find this?
2. There should be a predefined API to get the width of the string in pixels. If yes what is that API?
Any help would be highly appreciated.
Thanks,
Hari krishna.
|
|
|
|
|
Not sure if this will work for you, but have you tried using MeasureString? You can try something like this:
Dim g As Graphics
Dim size As New SizeF
Dim myFont As New Font("Arial",8) 'Just as an example, you can replace it with whatever font/size you are using
g=CreateGraphics()
size=g.MeasureString(myString,myFont)
g.Dispose
Don't forget to import System.Drawing.Graphics
Dominick
|
|
|
|
|
Dominick,
Thanks for the prompt response. Is there a way i can acheive this in VB?
Thanks,
Hari krishna.
|
|
|
|
|
That was VB, VB.Net... what are you working with if not VB.net?
|
|
|
|
|
The example I gave was VB.NET
|
|
|
|
|
Ok, I'm confused because the example presented to you earlier was in VB.Net, code done and everything. All you had to do was just tweak it a bit to suit your needs. But you didn't... you asked him how to use it...
|
|
|
|
|
If you're talking about legacy VB, then you can use the GdipMeasureString function in the gdiplus.dll file
|
|
|
|
|
What I would do personally is just make another label or textbox with autosize set to true and turn its visibility off, store whatever string in there and use check its height and width property to see how big the string is..
That is assuming I understood the question correctly.
|
|
|
|
|
Hello All,
Thanks for the replies.. I really appreciate your effort.
I did some research and finally found out the way to find Height and Width of the character (any language). I am posting this because i could see only questions on this and i didn't find any reply with the exact solution.
1. Get the handle to the desktop.
2. Get the device context using this desktop handle.
3. Create the font using CreateFont for particular font type.
4. Use selectobject to assign this font type to the device context.
5. GetTextExtentPoint32 to get the height and width of the character you want.
I followed the above steps and was able to get the results as expected.
Please excuse me if i am wrong somewhere..
Thanks,
Hari krishna.
|
|
|
|
|
Hello,
I have used a localized form for Turkish. However I am not able display any Turkish characters in the listview. It displays a questionmark (?) instead of the turkish characters in some entries in the listview.
How can I solve this problem?
Thank you.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
you can use encoding which support different format
try following
str="string with turkish character"<br />
Encoding.UTF8.GetString(Encoding.Default.GetBytes(str))
hope this helps
|
|
|
|
|
I have 2 tables in MS Access
Username is set as the primary key that relates both the tables
I want to insert fields into my second table from my form along with the Username from the first table
how can i do this?
can anybody help me on this?
thanks in advance
|
|
|
|
|
can u be more specific regarding ur need ?
=> U want to insert record in master table and then in detail table ? OR
=> U already have record in master table and insert in detail table ?
|
|
|
|
|
i need to insert in the detail table
master table and detail table has Username field unique
from the logon screen, username has to be fetched and stored in the detailed table and from another form few fields has to be inserted in the same table
in simple, i want to insert fields from two screens into a single(detailed) table
modified on Tuesday, February 3, 2009 8:16 AM
|
|
|
|
|
A Username is a very bad field to use as a key. Use an auto-incrementing number instead.
There are, literally, thousands of examples of how to do this on the web. All you have to do is search[^].
|
|
|
|
|
Dave Kreskowiak wrote: Use an auto-incrementing number instead.
Isn't that considered bad practice?
Can't recall any examples right now but I seem to remember that you could have a number of difficulty's with those.
|
|
|
|