Optimization :: Optimize Own Code Written?
Jan 20, 2011How can I Optimize my own code written by VB.net? Is there any tools for it? Does Visual Studio have any one? What's your suggestion? I use VS2008 as my editor.
View 1 RepliesHow can I Optimize my own code written by VB.net? Is there any tools for it? Does Visual Studio have any one? What's your suggestion? I use VS2008 as my editor.
View 1 RepliesOk, the error I'm getting is "Load Report Failed" and it happens when I need to load a large number of crystal ReportDocument objects. I've searched on this, and there is a property in the registry that you can change to -1 and it allows to load more, however I'm still getting the error, just after I get about twice as many documents loaded.
The report is basically a one page document (for each client in the database with an interest charge). It displays the amount of interest charged, and other information pertaining to the charge. These documents are basically printed out and mailed to the client.
I created a "Print Preview" screen which has a CrystalReportViewer object, and an ArrayList property. The ArrayList property has an array of all reports, and there are next and back buttons to browse through each report. Once they are satisfied, they will print them all out, and I can dispose of the objects.
The solution for this, from everywhere I've seen, is to "Dispose the object after you are done with it". My problem is that I can't dispose it until they are finished with the print preview screen.
Is there a better way to go about this that won't require too much time to code (we are already over the deadline on this project) or a simple solution to get past the ReportDocument limit? Right now it is erroring on report 150., There are 180 records (as of today) that need to be loaded.
The following code takes a timeframe in minutes since midnight and creates an array with minutes pr hour. But, it's slow. Any better suggestions out there? (no, changing language is not an option :-) )
Const clDeparture As Long = 123
Const clArrival As Long = 233
Dim lHour As Long
Dim lMinute As Long
Dim alHour(25) As Long
[Code]...
I came across the following code recently and would like to optimize it:Public Shared Function ComputeLabel(ByVal Action As Integer, ByVal Flag1 As Boolean, ByVal Flag2 As Boolean) As String
Dim Prefix As String = ""
If Flag2 Then
Prefix = "Conditional "
[code].....
I'm wondering if you know if there is a better way to write this code in order to speed it up. It has several blocks of if statements filling arrays, like this:
row0: If x < b(1, 1) Then a1(i, j + 1) = 0
If x > b(1, 1) And x < b(1, 2) Then a1(i, j + 1) = 30
If x > b(1, 2) And x < b(1, 3) Then a1(i, j + 1) = 60
[code].....
Public Function CalCheckSum(ByVal ByteList As List(Of Byte)) As List(Of Byte)
Dim total As Integer = 0
For Each b As Byte In ByteList
[code]....
When my form first loads, it runs at about 30k CPU, but after about 10 minutes of use, it goes up to (and stays at) about 70k CPU.
What ways can i optimize my code to allow the CPU usage to stay low, or how can i lower it during the running of the program.
My most concerned areas of the CPU are:
1. I have a web browser, and when a user types in a url and presses go or enter, the CPU jumps about 4k:
Private Sub Go_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Go.Click
WebBrowser1.Navigate(OldURL.Text)
[Code]....
The second worry is when i open other forms, it boosts the CPU up aswell. the only code for this is:
Form.Show()
this is in reference to my main post here update mdb with data from different tables in dataseti have two tables in a dataset called dsSource. dsSource.Tables(0) has the following columns: ,,,,,,,code,art,sizerng1,sizerng2,sizerng3,etc...... dsSource.Tables(1) has the following columns: ,,,,,,,code,art,size1,size2,size3,etc...... the conditions here are: 1) to look for "1" in columns sizerng1, sizerng2, etc. of dsSource.Tables(0) 2) match code and art on both tables finally if both conditions are valid then the size values in columns size1, size2, etc. will be assigned to columns in sizerng1, sizerng2, etc. my main concern here is i have to loop through all rows in both tables which takes a long time, so is there a better way to do this than the code i have below?.
'***put the sizes from weights to traps file
row1 = 0
For Each dr As DataRow In dsSource.Tables(0).Rows
[code].....
I found a very useful source code on how to make a fud cryptor, but the author didn't mention which coding language / software he used, please follow the link below, to see the full source code.
View 5 RepliesI have never used Visual Basic before.
I have some source code for a project to look at. How can I tell whether the code has been written in VB or VB.Net?
I have some code that was written in C# and am attempting to convert it to VB.Net, for the most part things have gone well but I am running into an issue that I am not sure how to handle. The project has several classes and a few namespaces defined. The issue is [or seems to be] related to the namespace usage.
In the C# code of one class I have
Code:
namespace GdiPlusLib
In another class I have
Code:
using GdiPlusLib;
When translated to VB I have in the first class above
Code:
Namespace GdiPlusLib
and the following in the other class from above.
Code:
Imports GdiPlusLib
I get the following warning message on the imports line
Namespace or type specified in the Imports 'GdiPlusLib' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases. There is another instance with a different namespace that gives the same warning and I get 11 errors all of which would seem to be related to the two warnings.
I'm currently using this method in calling batch files in vb.net:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
System.Diagnostics.Process.Start("F:ipconfigflushdns.bat")
End Sub
Is it possible to incorporate the code written in the batch file so that I won't have to call it like the one above?
I have written a code to generate random colors and the code is working perfectly fine.I have a requirement in which I should not generate Red or Shades of Red in Random Color function. suggestion on how to not generate Red and its shades
View 7 RepliesI would like to combine the two things in the title to use as a query for an access database. I think i kind of know what to do, but then it doesn't work so i actually dont, the error i am getting in runtime is that the query is incomplete. The line of code in question is this:
Query = New OleDb.OleDbCommand("Select key From '" & frmFrontEnd.cmbModel.SelectedIndex.ToString & "'_Assistant", AccessConn)
i want to make a website builder which has the html code already written so all you have to do is check which boxes you want and click next or back to go through the process of making a website with specific code implemented in it.
P.s. im using VB 2008 express edition?
I have been developing windows and web application using Visual Basic 2005 for a long time. Now i want to change from Visual Basic 2005 to Visual Basic 2008. I would like to know what ever projects i have done in visual basic 2005 will works in Visual Basic 2008. Will the existing code in visual basic 2005 supports Visual Basic 2008 or do i need lot of modification. I haven't used VB 2008 but i hear that most of the code which written in visual basic 2005 supports visual basic 2008. What are the things i need to take care when working the existing projects in visual basic 2008.
View 3 RepliesI have VB 2008 Express installed in my PC. I downloaded a program source code written in VB6 but could not open the files. What do I need to do to get this codes displayed.
View 4 RepliesI am trying to write code for a login to my program. But the code I have written freeze's the screen. Basicaly I want to check if username (TextBox1) has text in it and then check if password (Textbox2) has text in it. if either textbox has no text then a MsgBox show's with an OK Button. and then I dont want the program to run. I want The login form to reload so the user can insert thier username & password. the code I have is below.
[Code]...
Here's what I've got thus far:
Dim xpDoc As New XPathDocument(strXmlUrl & strXmlInfo(0) & "?xml=1")
Dim xpNav As XPathNavigator = xpDoc.CreateNavigator()
Dim xpExpression(9) As XPathExpression
[code]....
I have an small physics toy application I am developing. It works fine except the particles will not push each other away, only pull towards, I debugged that sub going through it command by command and realised the value 'H' would not change, what ever it was set to during the first pass through the sub is what it kept, the only way to change this value is to manually set it i.e 'h = 1'. Once the calculation is redone on the 'H' value it resets to what it was previously, even though the x1,y1,x2,y2 are all different, thus meaning H should be different.
I think it is me that has made a mathematical mistake somewhere, but I cannot see where it is. I need a fresh pair of eyes to look over my work. Please let me know if you find anything.
[Code]...
I have been developing an antivirus using vb.net. The virus scanner works fine but I was thinking of ways to optimize the scanning speed (because large files take forever)
View 3 RepliesIn a project of mine I'm currently doing this:
[code]...
all classes inherit docMain and addTemplateToList( X ) adds x to a List(Of docMain). Now my question is: Is there a better way to do what's done in the code sample? I thought of something like:
[code]...
Is this somehow possible in VB.net (Reflection?)?
I have a DataGridView where I bind a datasource (sql query) to it. The row count is high with many columns. Trying to scroll through this DGV is painfully slow.
Does anyone know of any kinds of optimization I can do so that I can scroll faster? Like what is the DataGrid doing when you scroll? Does it repaint every screenful? Does it validate every row? It seems like it is doing something unneeded when a user scrolls.
I am getting error in the following line of frmContacts.frm. The module code is quite right. I have mentioned the module code here just to give an exact idea .The error line is: .Connection = MyConnection (Wherever it is in the frmContacts.frm)The error read as : Name "Myconnection" is not declared.
Code in Module:
Imports System.Data.OleDb
Imports System.Data
Imports System.Windows.Forms
[code]....
I have written a code which does the thing as the title says. The problem is, the whole process took 10 minutes just for 1000 records. Here is the code:(Written in vb.net 3.5 and sql server ce)
MyConnection.Open()
Dim count As UInt32
cmnd = New SqlCeCommand(sqlstring, MyConnection)
[Code].....
i am trying to add a text file in Debug folder. But when i go to project tab to add a new item, there is no option to add a new item? What part of the setting needs to be changed? Using Visual basicExpress 2010.
View 1 RepliesI need to order lists of up to 100 addresses in optimized order. Is there a way to do this since getdirections is limited to 25? i don't se any way around this 25 limit. Is there one I'm missing?
No I'm trying to use MapPoint object model but it crashes as well with this many waypoints. Here is my example proof of concept code from Excel:
Sub OptimizeRoute()
Dim objApp As Object 'New MapPoint.Application
Dim objMap As Object 'MapPoint.Map
[Code]....
I had been working on a project that would generate a loan schedule.
But, It needs to factor in specified holidays and weekends.
Now, when running with a small 'term', it seems to work fine.[code]...
Consider this
bar = 1
foo = <1 or 2, depending on previous code>
if foo=1
while bar <= 5
[code].....
What I want to know is, is the compiler smart enough to optimize away the (apparently) repeated tests for "foo = 1" since foo is not modified in the body of the loop?If so, I might use the second construct since it is semantically equivalent (I think!), takes less code and reduces indentation levels.
I need a list from OldGuids that are not in the NewGuids, so I used the Contains method, the problem is that it is already running more then half hour, is there a faster way? or how much longer would it take about? [code]
View 2 Replies