|
Hi there basicly im creating programe about customers in rent car office and i need to print the application with vb2008 by clicking on the printer button
Regrads,
|
|
|
|
|
Take a look at the Printer and PrintDocument classes on MSDN.
There is also a PrintPreview class, if you want to provide that functionality.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Guys,
I have this weird problem in a VB6 application i am maintaining where an unexpected value is returned from addition of two doubles. One of those doubles is negative. Eg.
Dim tst As Double
Dim tst1 As Double
tst = -8.4
tst1 = 8.45
tst = tst + tst1
MsgBox tst
The Value of tst is 4.99999999999989E-02 when the MsgBox appears.
Anyone know whats going on here?
Thanks In Advance
|
|
|
|
|
For standard questions like this I have a standard answer:
The way floats/doubles are stored in binary makes it impossible to exactly represent
most values, especially the ones that seem like round numbers to humans thinking
using base ten.
So 4, 2, 1, 0.5, 3.5, 3.75 and many others are representable exactly (basically since
they all equal an integer divided by some power of 2); but 3.6 and 3.8 and an infinite
number of other values are not.
Now whatever float/double function you call, if it returns a float/double will suffer
from the same phenomenon. So the only way to really get "3.6" or "3.8" is by using a
function that not only rounds but returns a string. I trust there are some formatting
methods that do just that in every programming language; In .NET languages
ToString() should be one of them, given an appropriate format specifier.
If you want to know much more about this topic, here it is:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
BTW: to circumvent the floating-point rounding problem, especially for monetary
numbers, they introduced the "decimal" data type (which basically stores decimal
digits).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Cheers Luc,
I Knew it was something simple just could not put my finger on it, i found the following code will work:
Dim tst As Double
Dim tst1 As Double
tst = -8.4
tst1 = 8.45
tst = tst + tst1
<big>tst = Round(tst, 2)</big>
MsgBox tst
|
|
|
|
|
Hello,
I have a task that needs to be executed many times in a thread, so as to keep my GUI responsive. Right now I'm using the ThreadPool to accomplish the tasks, and it works perfectly. I get all the data I expect back from the threads, life's good.
When those tasks are finished, I then fire off another set of threads to accomplish another set of tasks, in the same fashion. The work method of these threads uses a call to RegistryKey.OpenRemoteBaseKey, which does exactly that, opens a remote registry key. The problem is: if the user running the application does not have permission to open the remote registry the call will throw an IOException, but I expect this behaviour because the user does not have permission to do it. However, the call itself can take FOREVER.
I wrote the application initially to use delegate methods and used the WaitHandle.WaitOne() method on AutoResetEvents in a state object I passed to each delegate. I tried the WaitOne method using a timeout, which worked fine until I realized that even though the WaitOne timed out, the thread was still running. This is a problem because (from what I understand) processes are only given a certain number of ThreadPool threads and, once used, they must be finished in order to be released back to the threadpool. In my work method, I also have a variable that can be signalled when the thread should be stopped, but that (obviously) only works on code that I've written.
So, my question is, how can I cancel a thread that's stuck on a .NET method? Is there some sort of garbage collection method I can call if I give it a handle? There has to be a way.
I've searched Google, MSDN and everywhere in between for solutions to this, but no one has an answer.
|
|
|
|
|
Brandon D. Legault wrote: how can I cancel a thread that's stuck on a .NET method?
You can't. You don't have any access to the managed thread pool threads themselves. If it's that critical, you'll have to implement your own threads to have greater control.
|
|
|
|
|
I apologize, but I really can't accept that. There has to be a way to do it.
I've tried using my own threads (by my own threads I assume you mean just a managed thread?) but I've read many many times that Thread.Abort is frowned upon, bad design etc... , also, it doesn't actually cancel the thread, it only flags it for cancellation, and waits for an appropriate time to cancel it.
OpenRemoteBaseKey isn't the only .NET method that works this way. ManagementScope.Connect(), which I also use to retrieve information in this application (and need to be able to cancel as well), is written similarly in that you cannot cancel it once you start it.
Without being able to cancel them, I don't see any practical functionality in either of these two methods (or any other .NET methods that work like this). I shouldn't have to write my own wrapper around the native methods *shudder*, to expose a functionality that should be shipped with these methods in the first place.
|
|
|
|
|
OK. Since the ThreadPool threads are completely encapsulated and insulated from your code, have fun with it!
|
|
|
|
|
|
Hi,
ThreadPool threads have their limitations, threads have a IsThreadPoolThread property, and when true, there are a couple of things you can't do. if you're not happy with it, use something else:
- BackgroundWorker;
- regular Threads.
The best article ever on threads is here[^].
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I have a project in vb.net2008. Having Forms only 8 and 2 classes and 1 module, and 1 Splash screen
& 1 crystal report ..
From the 8 forms, 4 forms I used Data Gridview class object & 3 forms Crystal report 1 for screen design.
But it's showing the memory size for whole project 417-MB, is it true? Is it nature of vb.net 2008?
Or I have virus?
And Publish-setup.exe is 452 kb only...
Is it normal behavior? or virus?
Thanks
|
|
|
|
|
It's just a Visual Studio thing.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Dear VBscript experts,
I have the following requirement which can be done in VB script . I am new to this forum and
am sure i will learn a lot by your valuable hints .
requirements are
- the log file should be deleted if the files are older than 400 days
- the log files from the server should be kept in the backup folder for 185 days.
Script should check the following:
1. Check if a file c:\\emailmoniroing\\logs\EmailLogyymmdd.log exists where ‘yymmdd’ denotes today’s date If it does
not, create a new file.
2. For each file in the ‘c:\\emailmonitor\main’ folder, check file size.
3. If file size=0, then move the file from the 'c:\\Emailmonitoring\main' folder to the ‘ c:\\emailmonitoring\backup’
folder
4. If file size >0, then read/append contents of the file to c:\emailmonitor\logs\EmailLogyymmdd.log. Move the file
read from the
'c:\\Emailmonitoring\main' folder to the ‘ c:\\emailmonitoring\backup’ folder
5. Delete all files older than 'x'' months from the c:\\emailmonitoring\backup folder
6. Delete all EmailLogyymmdd.log files older than ‘x’ months from the folder ‘c:\\emailmonitoring\Logs’
Finally,
Set up a windows scheduler task to run the new script every 20 minutes or it can run continuously, sleep and wake up
every 5 minutes
Could you provide any sample script something to acheive the above. it will be very useful to meet our business needs.
Thanks in advance
regards
pannar
|
|
|
|
|
Option Explicit
' Variable declaritions
Dim fso, f, f1, fc,sf
Dim colSubfolders
Dim objSubfolder
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("C:\poetic\logs\Emailmonitoring")
Set fc = f.Files
Set colSubfolders = f.Subfolders
For Each objSubfolder in colSubfolders
'Wscript.Echo objSubfolder.Name, objSubfolder.Size
If((objSubfolder.Name = "backup") Or (objSubfolder.Name = "logs"))Then
Set sf = objSubfolder.Files
'log files under backup folder should be deleted if the files are older than 400 days
For Each f1 in sf
If DateDiff("d", f1.DateLastModified, Now) > 1 Then
f1.Delete
End If
Next
End If
Next
Set colSubfolders = Nothing
Set sf = Nothing
Set fso = Nothing
Set f = Nothing
Set fc = Nothing
|
|
|
|
|
Hi All,
How can i rotate Label to 90° Angle.
Thanks
If you can think then I Can.
|
|
|
|
|
|
Here is an article on codeproject with another good control to do this <a href="http://www.codeproject.com/KB/miscctrl/customtext.aspx">Customized Text - Orientated Controls in C# - Part I (Label Control)</a>[<a href="http://www.codeproject.com/KB/miscctrl/customtext.aspx" target="_blank" title="New Window">^</a>]
I know it is c# but it could easily be translated into VB.NET using <a href="http://www.icsharpcode.net/OpenSource/SD/">Sharp Develop</a>[<a href="http://www.icsharpcode.net/OpenSource/SD/" target="_blank" title="New Window">^</a>] or similar.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
Hi,
I had also tried with following code but gives an error
rss.Open("select max(orderno) As ono from measurementblazer where custno='" & txtcustno.Text & "' AND blength<>0 ")
o.order_no = rss.Fields("orderno").Value // here comes an error
//Item cannot be found in the collection corresponding to the requested name or ordinal.//
This error comes because in table there is no record found for requested customer.
Please help.
Thanks,
|
|
|
|
|
Try this: o.order_no = rss.Fields("ono").Value
You named the field 'ono' in your query: ...select max(orderno) As ono from...
Tosch
|
|
|
|
|
Hi,
I am trying with the same code but there is same error
Thanks,
|
|
|
|
|
AjitMourya wrote: o.order_no = rss.Fields("orderno").Value // here comes an error
Why not check first if you got a result ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Answered in this forum, in this[^] thread, just a few hours ago.
..and yes, I have verified whether the query works in Access
|
|
|
|
|
Hi Experts ,
I want the code or solution to suppress the strings(-) in crystal report.
There is functionality to suppress zero.
Thanks,
|
|
|
|
|
You can suppress a text field by checking the suppress box in the format editor of a textbox.
Tosch
|
|
|
|