|
I declare a brush... Dim lBrush as SolidBrush
Then I use it lots of times in a function for different things like gradient fills. So I might do...
lBrush = new GradientBrush...
Then again...
lBrush = new GradientBrush...
You get the idea. Should I call lBrush.Dispose before I say lBrush=New brush....
If I don't, do I get a memory leak?
Sounds like a waste of time, unless you have an object that is going to be in scope for a long time using transient resources that should be released quickly.
Thanks 4 ur help guys.
Nursey
|
|
|
|
|
The general rule is yes, of course.
Objects that expose the IDisposable interface do so because they contain resources that a limited in some way. The destructor/finaliser of these objects will call Dispose anyway, but is it better to call Dispose when you know you don't need the object any more. Why? Because you don't know when the garbage collector will clean up after you, which could mean that you run out of the resource and are then left wondering why your program failed.
So... If its got an IDisposable interface then use it.
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
|
|
|
|
|
I was pretty disappointed when I first looked over the RichTextbox component and seen that they didn't include UTF-8 as one of the Format Options (since it is available in V 3 of the control). What I'd like to do is extend the loadfile/save file function by creating a class or module that contructs the RichEdit's EditCallback function so that I can then use SendMessage to Streamin and Streamout the data. I've done this before in VB6 -- but I can't seem to get the code to work in vb.net because I don't understand how to generate the EDITSTREAM structure. I'd like to pass a filestream handle into the Callback, but I can't figure out how to create the EDITSTREAM structure so that dwCookie will allow the handler and then how to use that handler in the Callback. I'm wonder if anyone here has done something like this (or maybe has C# or C++ code that they wouldn't mind sharing -- or better yet, coverting) or maybe knows of another way that I could load UTF8 data into a RichTextbox.
Thanks
|
|
|
|
|
Does anyone have an example of how they implemented the singleton design pattern in Visual Basic 6.0.
|
|
|
|
|
For anyone who cares...I found an old article from Visual Basic Programmers Journal that will help with the Singleton issue.
VBPJ article[^]
Good luck.
|
|
|
|
|
Does VB 6.0 static the same as C++ static?
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
I need to find out the printable area on a page, vb.net either give me the paper size or the size after margin, which is set by the user.
I used the API to find that in VB6, does vb.net expose that property or do we have to go back to API?
Thanks,
Tao
|
|
|
|
|
If it does, it's very well hidden! Best bet looks like API again.
RageInTheMachine9532
|
|
|
|
|
I'm trying to set a property in the following class:
<system.runtime.interopservices.guidattribute("3050f558-98b5-11cf-bb82-00aa00bdce0b"), system.runtime.interopservices.coclassattribute(mshtml.ceventobjclass)="">
Public Class CEventObj
Member of mshtml
The property is:
<system.runtime.interopservices.dispidattribute(1007)>
Public Property returnValue As Object
Member of mshtml.CEventObj
When I try:
Dim objevent As New mshtml.CEventObjClass() OR
Dim objevent As New mshtml.CEventObj() OR
Dim objevent As New CEventObjClass() OR
Dim objevent As New CEventObj()
I get the following error, also the CSLID from the Object Browser of 3050F558-98B5-11CF-BB82-00AA00BDCE0B is different from the COMException error message
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Test Form .exe Additional information: COM object with CLSID {3050F48A-98B5-11CF-BB82-00AA00BDCE0B} is either not valid or not registered.
The Registry states the CSLID 3050F48A-98B5-11CF-BB82-00AA00BDCE0B from COMError message is the following:
HKEY_CLASSES_ROOT\CLSID\{3050F48A-98B5-11CF-BB82-00AA00BDCE0B}...
default(not set)
HKEY_CLASSES_ROOT\CLSID\{3050F48A-98B5-11CF-BB82-00AA00BDCE0B}\InprocServer32...
Assembly(Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
Class(mshtml.CEventObjClass)
Runtime version(v1.0.3705)
The Registry states the CSLID 3050F558-98B5-11CF-BB82-00AA00BDCE0B from the Object Browser view is the following:
HKEY_CLASSES_ROOT\Interface\{3050F558-98B5-11CF-BB82-00AA00BDCE0B}
default(DispCEventObj)
HKEY_CLASSES_ROOT\Interface\{3050F558-98B5-11CF-BB82-00AA00BDCE0B}\ProxyStubClsid...
default(00020420-0000-0000-C000-000000000046)
HKEY_CLASSES_ROOT\Interface\{3050F558-98B5-11CF-BB82-00AA00BDCE0B}\ProxyStubClsid32...
default(00020420-0000-0000-C000-000000000046)
HKEY_CLASSES_ROOT\Interface\{3050F558-98B5-11CF-BB82-00AA00BDCE0B}
TypeLib(3050F1C5-98B5-11CF-BB82-00AA00BDCE0B)
Just to be sure I ran regsvr32 mshtml.dll sucessfully
What is going on? the CSLId from the COMException InprocServer32 points to Class(mshtml.CEventObjClass). H E L P!
Thanks, GregC
|
|
|
|
|
I have a number which is in microseconds and need to convert it into a time and date.
CHighTime class (written in C++) was used to make this number by another vendor and now I am trying to convert it back using VB.net any help would be appreciated.
The number is a 64 bit value (in microseconds), and is the number of 1 microsecond intervals since January 1, 1601.
Another way of asking this question is how do you use the chightime class within a VB.net project?
|
|
|
|
|
You can't use the code directly. You'd have to either rewrite it in VB.NET or compile it directly into a .DLL and use it that way.
The other option is to look for other high resolution timer controls such as the CCRP High Performance Timer Object, which can be found here[^].
RageInTheMachine9532
|
|
|
|
|
Hello,
I'm trying to set up a report so that it will have several different columns for the same set of fields (like creating columns in word) that my data will be displayed in. For example... I have about 100 records to display on each page of the data report... The way it is right now, if I want to print out a report of those records it prints off several pages with just one column of the set of fields. I want to set up multiple columns for the same fields so that they will all fit on one page.
Instead of having
Field1 Field2 Field3 on a page, I will have
Field1 Field2 Field3 : Field1 Field2 Field3 : Field1 Field2 Field3 on a page
I hope that made sense. Thanks so much for your anticipated help.
TimDasa
|
|
|
|
|
How are you generating the report? Using Crystal Reports? Or are you using code you wrote to send data to the printer?
How are you tracking your data? Using a RecordSet object? Or using an Array?
Need just couple more details here!
RageInTheMachine9532
|
|
|
|
|
Thanx for your response.
I have the data in a microsoft access database. I designed the report using vb 6 data report which gets it data from a data environment. I then used an SQL statement to filter the records.
If you have a better way of extracting the data from the tables pls let me have it.
Thanx.
|
|
|
|
|
OK. In that case, you should be using a RecordSet object to track the data in your app.
Next, you didn't mention how you were generating your report, so I'll assume your writing the code for it yourself.
Now, you'd have to print the data out, something like this (assuming 50 rows per column):
Rec(0).Field1 Rec(0).Field2 Rec(0).Field3 : Rec(50).Field1 Rec(50).Field2 Rec(50).Field3
Rec(1).Field1 Rec(1).Field2 Rec(1).Field3 : Rec(51).Field1 Rec(51).Field2 Rec(51).Field3
A simplified view of the code might look something like this (not actual code):
Dim Index as Integer
Dim rsData as RecordSet (Your data is in here)
Dim strOutput as String
'Output your headers here
'
For Index = 0 to rsData.Count - 1
strOutput = rsData(Index).Fields(1).ToString & " " & _
rsData(Index).Fields(2).ToString & " " & _
rsData(Index).Fields(3).ToString
Try
strOutput = strOutput & " : " & _
rsData(Index + 50).Fields(1).ToString & " " & _
rsData(Index + 50).Fields(2).ToString & " " & _
rsData(Index + 50).Fields(3).ToString
Catch
End Try
Print strOuput
Next
Again, this is a greatly simplified example and will NOT compile! But it should be enough to give you an idea of what is going on.
RageInTheMachine9532
|
|
|
|
|
please tell me difference in detail between com component and .net component
tbhattacharjee
|
|
|
|
|
say suppose there is lots of parent and child nodes in treeview and checkbox is attached with all the nodes and i want to show the name of node which checked.please help me with sample code.
tbhattacharjee
|
|
|
|
|
please tell me how can i insert picture in the cell of the datagrid and provide small sample code.
tbhattacharjee
|
|
|
|
|
http://aspalliance.com/articleViewer.aspx?aId=141&pId=
http://www.dotnetbips.com/displayarticle.aspx?id=101
try to visit the site and you see the sample codes.
Dabuskol
|
|
|
|
|
Hello, I am tring to create a program to help my work schedual Pull Stock. I have a problem getting the value of the variables into a spreadsheet. This is some test code I am trying to get to work:
Public Sub Insertdata()
'Insert data typed in txt boxes into ExcelData1.xls
Dim conn1 As New System.Data.OleDb.OleDbConnection(m_sConn1)
conn1.Open()
Dim cmd As New System.Data.OleDb.OleDbCommand()
Dim strID As String
Dim strName As String
Dim Birthdate As Date
strID = txtID.Text
strName = txtName.Text
Birthdate = txtBirthdate.Text
cmd.Connection = conn1
'******Here is where the trouble is***********************
cmd.CommandText = "INSERT INTO [EmployeeData$] (ID, Name, BirthDate) values (strID, strName, Birthdate)"
'****** the values of:(strID, strName, Birthdate)will not pass**********
cmd.ExecuteNonQuery()
conn1.Close()
End Sub
Any advice would be greatly appreciated
Thanks!
|
|
|
|
|
DawgTagz wrote:
'******Here is where the trouble is***********************
cmd.CommandText = "INSERT INTO [EmployeeData$] (ID, Name, BirthDate) values (strID, strName, Birthdate)"
You might want to try this instead:
cmd.CommandText = "INSERT INTO [EmployeeData$] (ID, Name, BirthDate) values (" & strID & "," & strName & "," & Birthdate & ")"
That way, you're passing the actual values of strID, strName, and Birthdate instead of the text string "strID, strName, Birthdate".
RageInTheMachine9532
|
|
|
|
|
Thanks! I will try that tonight.
|
|
|
|
|
Nope, That didn't work. I keep getting:
"No value given for one or more parameters."
|
|
|
|
|
Even when I try passing the actual value of the textBox instead of the variables.
|
|
|
|
|
In that case, it's the SQL INSERT statement that is bad or not formated correctly.
After looking up the INSERT statement on MSDN, I've found that it should look something like this:
cmd.CommandText = "INSERT INTO [EmployeeData$] (ID, Name, BirthDate) values ('" & strID & "', '" & strName & "', #" & Birthdate & "#)"
Where string values must be enclosed in single quotes. Date values must be passed something like #1/1/1999# (enclosed in pound signs).
I haven't tested this, but it should work according to the docs. You might have to make sure that the Birthdate gets passed in the correct format.
RageInTheMachine9532
|
|
|
|