|
Dispose() does not set the object to Nothing, you need to do that yourself. I am guessing the extra code creates time for something to happen in the framework. Ultimately, you're struggling against a bug in .NET, I believe if you change the way you load your image, you can get around this.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Christian Graus wrote: I am guessing the extra code creates time for something to happen in the framework
Thanks Christian.
I moved the dispose() statement to the function that creates the new image. That seems to have solved the problem. If worse come to worse, I can probably drop a timer into the code somewhere.
|
|
|
|
|
Hey,
I am trying to print an overview with a For Each loop. Now, in this loop I check whether the current Y position exceeds the pages maximum Y, and if so, I set e.HasMorePages to True . However, this isn't working. It keeps printing and printing while it shouldn't. Here is an example of my code. (In the PrintDocument.PrintPage Event)
For Each Uitgave As Xml.XmlNode In UitgavenNode.ChildNodes(MonthToPrint).ChildNodes
...
StartY+=PrintFont.GetHeight
If StartY >= e.MarginBounds.Height Then
StartY = e.MarginBounds.Y
e.HasMorePages = True
Else
e.HasMorePages = False
End If
Next
So the bottom line is: When StartY >= e.MarginBounds.Height then it must jump to a blank page and continue printing. Please note that this all happens within a loop and printing must continue at the same position within the loop.
Please tell me what's wrong with this code, so I can fix it
Thanks in advance,
Zaegra
Motivation is the key to software development.
|
|
|
|
|
The PrintPage event is fired for each and every page that gets printed. Your code sample is a bit incomplete, but it looks like you're printing the same thing on every page. Are you printing only what fits on a page, saying the point in the loop that you're at and restarting the loop at the point you saved in the previous handling of the PrintPage event.
|
|
|
|
|
Hi there, I'm trying to migrate an existing vb6 mail application to vb 2008 but it fails conversion. Anyway I'm looking for a module to send email with attachments using outlook 2003. Code must be written in vb 2008. What I can't get is attaching a document to the email! What I have so far is:
Module Module1
Dim app As Object
Dim itm As Object
Dim myItem As Object
Dim myAttachments As Object
Sub sendmail()
app = CreateObject("Outlook.Application")
itm = app.CreateItem(0)
With itm
.To = "someone@yahoo.com"
.CC = "someone@hotmail.com"
.Subject = "test"
'.importance = "high"
'.BodyFormat = Microsoft.Office.Interop.OutlookolFormatHTML
.Body = "Test message"
.send()
End With
MsgBox("message sent", vbOKOnly, "sent....")
End Sub
End Module
All I do is call the sendmail() function from a cmd button! There are other example send mail applications out there but they are written in vb.net and uses smtp(which I don't need)
|
|
|
|
|
I'm pretty sure that itm should have an attachment property.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I hope it did, but vb2008 is different from vb6 (which had the attachment property).
|
|
|
|
|
It doesn't matter. The object you're using are not exposed by VB6 or VB.NET. They are exposed by the COM-based classes you are creating instances of. The properties would be identical.
|
|
|
|
|
I use this
Dim oMail As System.Net.Mail.MailMessage
Dim oFrom As System.Net.Mail.MailAddress
Dim oSmtp As System.Net.Mail.SmtpClient
oMail = New System.Net.Mail.MailMessage
oFrom = New System.Net.Mail.MailAddress("me@here.com")
oSmtp = New System.Net.Mail.SmtpClient("mail.here.com")
oMail.From = oFrom
oMail.To.Add("him@here.com, him@there.com, another@there.com)
oMail.Subject = "My Subject"
oMail.Priority = Net.Mail.MailPriority.Normal
oMail.IsBodyHtml = True
oMail.Body = "Body of rmail here"
oSmtp.Send(oMail)
|
|
|
|
|
Does this piece of code require you to setup an smtp server in IIS? If it does, then this piece of code will not work in my case. All I want to do is send an email with an attachment via outlook 2003 (connects to microsoft exchange) and the code needs to be compatible with vb2008.
My first post has working code (in vb2008) that can send email with outlook 2003, BUT without attachments!
|
|
|
|
|
I guess all you need to add is this line
<br />
.Attachments.Add("c:\myfolder\myfile.txt")
But this gives me security warning.
I will try to find how to avoid it.
Like car accidents, most hardware problems are due to driver error.
Samir R. Ibrahim
|
|
|
|
|
I have now switch to office 2007 and adding these lines worked perfectly:
' Add an attachment
Dim sSource As String = "C:\somefile.extension"
Dim sBodyLen As String = oMsg.Body.Length
Dim sDisplayName As String = ""
Dim oAttachs As Outlook.Attachments = oMsg.Attachments
Dim oAttach As Outlook.Attachment
oAttach = oAttachs.Add(sSource, , , sDisplayName)
oMsg.Send()
|
|
|
|
|
how to create round shapes??
could this work-
in a label(backcolor set equal to form's) set a round image.
won't this increase the cpu time??
i am looking for an efficient way to create a round shape
like in vb6 we'd just chose the shape control.
but in vb2008 all controls that don't have handles are dropped
is there a way to do so??
eh?
TheMrProgrammer
|
|
|
|
|
System.Drawing.Graphics provides the facility to create diffrent types of shape as you want.
Set your Backcolor as forms color or set it to transparent.
If you can think then I Can.
|
|
|
|
|
Or you can Google for the "VB.NET Power Packs". The 3.0 version has shape controls in it like those that used to be in VB6.
|
|
|
|
|
hi
modified 28-Nov-12 8:23am.
|
|
|
|
|
|
Using cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DB\E_Ensemb.mdb")
check this
remove only the ; from the end
|
|
|
|
|
I need to directly connect to the .dbf files and not with the .mdb files...
|
|
|
|
|
.dbf is DBase file which belong to VFP (Visual Foxpro)
I use this to connect
Dim _cnn As New OleDb.OleDbConnection("Provider=VFPOLEDB.1;Data Source=F:\myfolder\myfile.dbf")
If you don't have VFPOLEDB in your ODBC, install the driver from here
Microsoft OLE DB Provider for Visual FoxPro 9.0[^]
Like car accidents, most hardware problems are due to driver error.
Samir R. Ibrahim
|
|
|
|
|
|
Thanks to all who replied.
The links really helped.
|
|
|
|
|
The value of w doesnt increase or decrease once it reaches the value 2 .. can someone please tell me why..
Thanks in advance
<br />
Public Class Form1<br />
Dim g As Graphics<br />
Dim db As Boolean<br />
Dim x As Integer = 100<br />
Dim y As Integer = 100<br />
Dim w As Integer = 150<br />
Dim h As Integer = 150<br />
<br />
<br />
Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel<br />
Console.WriteLine(e.Delta.ToString)<br />
If (e.Delta > 0) Then<br />
Console.WriteLine("in zoomin")<br />
w = w * (e.Delta / 100)<br />
Console.WriteLine("inside zoomin e.delta " & e.Delta.ToString)<br />
Console.WriteLine("w" & w)<br />
h = h * (e.Delta / 100)<br />
End If<br />
If (e.Delta < 0) Then<br />
Console.WriteLine("zoomout")<br />
w = w / ((e.Delta * -1) / 100)<br />
h = h / ((e.Delta * -1 / 100))<br />
<br />
End If<br />
Console.WriteLine("w" & w)<br />
Me.Refresh()<br />
End Sub<br />
<br />
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint<br />
<br />
e.Graphics.DrawRectangle(Pens.Black, x, y, w, h)<br />
End Sub<br />
<br />
End Class<br />
<br />
|
|
|
|
|
I suspect the answer is that even if VB doesn't round e.Delta/100 to an int, once it rounds the end result to an int, it's going to not be big enough to get past 2 in either direction. Do e.Delta / 100.0 to make it work with a float, and consider what you do when the end result moves the value by less than .5, which means it will round back to what it was. Perhaps you need to store w as a float, and make it an int only when you're using it to draw with.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Public Class Form1
Dim g As Graphics
Dim db As Boolean
Dim x As Integer = 100
Dim y As Integer = 100
Dim w As Integer = 150
Dim h As Integer = 150
Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
Console.WriteLine(e.Delta.ToString)
If (e.Delta > 0) Then
Console.WriteLine("in zoomin")
w = IIf((w * (e.Delta / 100)) < 3, 3, (w * (e.Delta / 100)))
'w = w * (e.Delta / 100)
Console.WriteLine("inside zoomin e.delta " & e.Delta.ToString)
Console.WriteLine("w" & w)
h = IIf((h * (e.Delta / 100)) < 3, 3, (h * (e.Delta / 100)))
'h = h * (e.Delta / 100)
End If
If (e.Delta < 0) Then
Console.WriteLine("zoomout")
w = w / ((e.Delta * -1) / 100)
h = h / ((e.Delta * -1 / 100))
End If
Console.WriteLine("w" & w)
Me.Refresh()
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
e.Graphics.DrawRectangle(Pens.Black, x, y, w, h)
End Sub
End Class
dinvit83
|
|
|
|