Incrementing Array Of Numbers - Optimizing Code?

Sep 8, 2010

I have code that increments an array of numbers. However, due to performance issues, I need to optimize it.
Here is the code:
Public Sub increment(ByRef Index() As UInt16)
Dim N As Integer = Index.Length - 1
If (Index(0) = 65535) Then
Index(0) = 0
[Code] .....

View 18 Replies


ADVERTISEMENT

Another OPTIMIZING Macro Vba Code For Excel 2007 - The Code Is A Sort Of Transposer For Data

Sep 9, 2011

this code was not done by me originally and there are some thigns here i dont quite understand i have altered it a bit from my coworkers code to suit my data and it works. but too slow. and when i have 4000+kb excel files it might freeze altogether. ( I have checked tho that when and after this transposer runs it will still be within the excel row limit, i had done calculations before and made a macro to automatically split excel files based on number of columns and rows to make sure this is so ). This code seems to start out fast then goes slower the longer it runs. at least this is what it seems liek to me.

[Code]....

View 2 Replies

VS 2010 Optimizing Byte Array To String Encoder

Feb 4, 2011

below is a byte array to string encoder. It uses the yEnc algorithm that is used for Usenet binaries (Usenet only supports text).

Doing a performance analysis in VS2010 shows that this is the most CPU intensive part of the application.

The encoder function is used thousands of times, so I'd like to optimize it as much as possible.

I'm using 'ReDim Preserve' instead of 'Take()ToArray', because I'm targeting .NET Framework 2.0. Is there a more efficient way of getting only a part of a byte array?

vb.net
'Values for yEnc Encoder
Public Structure EncoderValues
Public lChar As Byte

[Code].....

View 15 Replies

VS 2008 Optimizing MySQL Connection Code

Aug 4, 2009

As I was starting on my lil project i realized that I would have a tonne of repetitive code. But wasn't sure how best to go around to just only have it in there once and just call on it. Not entirely sure how to do this as I havnt done it before, I was trying to mess around with it in a Function type thing but I had declaration issues which put me off course. Basically they'll be a few labels lbl8Beats(on click it loads the table in the datagrid (dgvCompositions)) is the first, and all the code from Dim conn As MySqlConnection to data = New DataTable, will be repeated.When i was messing around and thought I'd open the connection on form load, and I just had a bunch of declaration issues, and was unsure how best to go about this. Also since the Adapter = "would be changing on each label it just made me more confused.[code]

View 1 Replies

Code - Incrementing The Loop?

Aug 5, 2011

What is the += used in this code doing? Is that incrementing the loop?

Public Class Form1
02
Public Structure Family

[CODE]..........................

View 2 Replies

VS 2008 - Make A Loop From 1 To 100 And Make It Everytime It Loops Display Incrementing Numbers To The Screen?

Aug 23, 2009

How do I make a loop from 1 to 100 and make it everytime it loops display incrementing numbers to the screen?

View 1 Replies

Optimizing GUI In VB?

Aug 11, 2010

I'm building a GUI that displays a lot of thumbnails. I'm currently using PictureBoxes that I dynamically allocate to do this. In the worst case I may need to display as much as 1000 of these thumbnails at once. I need the thumbnails to move around and animate fluidly. PictureBoxes hog a lot of memory.

View 16 Replies

Optimizing A Function?

Apr 27, 2009

I have a function which is executed a lot of time during a flat file (txt) import. (50 000+)using a profiling tool the attached function where identified as 40% of the runtime..The code works as is.. But should be a lot quicker..

The code converts the following format 5710.436' N to the double representation.
DMS -> DD
MS Degrees:Minutes:Seconds (4930'00"N, 12330'00"W)

[code]....

View 3 Replies

Asp.net - Optimizing SQL Data Reader?

Aug 10, 2009

I am using SQl data reader to get value from SQL database.Language VB.NET.After getting data into reader, i run a while loop

While reader.Read

If reader.HasRows() Then

/* Proessing of data *[code]....

View 3 Replies

Optimizing File Explorer?

Nov 11, 2011

I'm working on a FTP Client, I started loading the local directories of my PC. I'm a university student of Computer Science. I had problems with my code, because it takes approximately 35 seconds to load all the directories and sub directories to a TreeView that in the future I will use to navigate thru my computer folders and pass files & olders to the FTP.

Option Strict On
Option Explicit On
Imports System.Collections.ObjectModel

[code].....

View 3 Replies

Optimizing Division/exponential Calculation?

Apr 15, 2010

I've inherited a Visual Studio/VB.Net numerical simulation project that has a likely inefficient calculation. Profiling indicates that the function is called a lot (1 million times plus) and spends about 50% of the overall calculation within this function. Here is the problematic portion

Result = (A * (E ^ C)) / (D ^ C * B) (where A-C are local double variables and D & E global double variables)

Result is then compared to a threshold which might have additional improvements as well, but I'll leave them another day

View 4 Replies

Time Out Error - Solve It Rather Than Optimizing?

Apr 8, 2010

I have a lengthy query..always it shows timeout..I am filling it in a dataset, not using command execute.Is there anyway to solve this rather than optimizing the code? any way to solve the timeout..

View 3 Replies

VS 2010 Optimizing Merging Of An Image?

Apr 6, 2011

I'm having a speed issue with some drawing in a program I am working on. I have narrowed down the speed issues to a single function. The cost of this function is such that I really need to find a way to make it faster, and that should be possible.

The function is this:

Public Shared Sub SuperImposeFishAni(ByVal bckGrnd As Drawing.Bitmap, ByVal dtop As Integer, ByVal dleft As Integer, ByVal dwidth As Integer, ByVal dheight As Integer, ByVal ImageInQuestion As FishImages)
Dim tp As Integer = 0

[code]....

This is actually a holdover from an earlier design that included animation, but that's probably irrelevant. What is happening here is that a bitmap (bckGrnd) is passed to the method along with the left, top, width, and height that are to be drawn, and a single variable to select which image to draw.The image to draw is chosen in the select statement, which makes up the bulk of the method. The guts of the issue are the last few lines.

Through profiling, I was able to determine that if this method is called, the drawing takes over .25 seconds, whereas if this method is not called the same exact drawing takes less than .07 seconds. Therefore, I am getting a significant slowdown from this one method, which surprises me, as it is pretty straightforward. It pretty much has to be this method, too, because I can perform the same actions with or without this method being called. It is called if a Boolean is True, which is about as fast a test as can be performed. If the Boolean is False, this method is not called. The >3x difference in timing is with or without this method.

The point behind the method is that the image from the select statement has to be superimposed onto the background image, and the size of the area, as well as the location, that it gets superimposed onto is almost totally arbitrary, which is why the size and location has to passed to the method.Technically, choosing the bitmap to merge in (the select statement), could be avoided, but I doubt that is the issue.

View 21 Replies

.net - Optimizing Loop For Vba Macro Excel 2007?

Sep 9, 2011

I have this code that works. it goes down a range and deletes the empty rows, seperates the first character into a different column if its not a number or negative sign.This code WORKS. but it is too SLOW for the amount of data i need it to deal with. I have already turned off automatic calculations. screen updating.and visibility of application.

[Code]...

View 3 Replies

Optimizing Loop For Vba Macro Excel 2007?

Dec 28, 2011

I have this code that works. it goes down a range and deletes the empty rows, seperates the first character into a different column if its not a number or negative sign

View 1 Replies

Check To See If At Least 3 Numbers In The Array Are The Same?

Feb 8, 2009

I have a question about working with arrays

I don't have any code written out I just want to know the best way to do this sort of senario to put into a flowchart, the program i'm working on isn't homework, its just practice and the book I have is less than helpful with what i'm working on.

I want to check to see if at least 3 numbers in the array are the same but no less so that it meets a certain requirement how would I check this?

View 3 Replies

Matching Numbers In An Array?

Jan 11, 2011

I am working on an application that llops through a dataset. Within each loop, I need to test to see if the datarow number is contained within an array. For example:For Each Page in Pages Test to see if page number is found in array (i.e. page number = 3, array = 1, 3, 4, 7, 8)Next Page The test would match on record numbers 1, 3, 4, 7, 8.

View 2 Replies

Numbers Change When Put Into An Array?

Jun 2, 2011

I have a datagrid in my form and numbers are input it. I then loaded one of the columns into an array. This is the piece of my code that loads the array:

Me.dgv.CurrentCell = dgv(1, 0)
For i = 0 To (Me.dgv.RowCount - 1)
Receipts(i) = Convert.ToSingle(dgv(1, i).Value)
Next i

The first value is -2912895.29. I put the program in break-mode and it keeps loading the first value as -2912895.25. I checked and it loads all of the values a few cents off.

View 2 Replies

Random Numbers In Your Array?

Feb 22, 2011

How Can I random the numbers in my array but they will not repeat the array value. The array number starts from 11 to 14.

Or how can I random 4 buttons.text that uses array to call their text?

View 4 Replies

Shuffle Array Of Numbers?

May 16, 2012

I am trying to shuffle an array of numbers it is randomizing but the numbers are been repeated is not what I need., I need the array to be shuffled but keeping the same numbers.For example if I do a first shuffle numbers may look like this in random order

2,4,5,1,3

Next shuffle maybe

3,5,4,2,1 and so on

But my problem is it repeating e.g. like this.

0,3,3,4,5 or 4,5,5,3,3

[code].....

View 2 Replies

.net - Incrementing The Filename?

Jun 7, 2011

Possible Duplicate: Way to get unique filename if specified filename already exists (.NET)Have a look at the following code:

Dim counter As Integer = 0
While System.IO.File.Exists("C:DesktopSample.xls")
counter = counter + 1

[code].....

View 5 Replies

Incrementing A Value In The Registry By 1?

Jul 18, 2010

I'm trying to increase the value of a registry entry by 1

HKLMSoftwareMyApp
Key = Test
Value +1

[Code]....

View 2 Replies

Array - Randomly Generate Numbers

Apr 14, 2010

I am making an application that randomly generates numbers. I then have to find out if those numbers are even or odd. Then place them in the corresponding array ( EvenNumbers() or OddNumbers() ). Then display the random numbers array then the even and odd numbers array. I am up to the point where I have the generated numbers and can tell if they are even or odd, but can't get them into an array. I am trying to do it like this....

[Code]...

View 10 Replies

Array And Use Of Flag To Shuffle Numbers?

Apr 10, 2011

i am trying to find out how it shuffles the number 1, 2, 3 and 4 without repeating the same number within the series. So far, I think that "i" begins as 1 and RN is a randomized number between 1 and 4. The do while loop checks if "i" is the same as RN and spits out the flag as true or false. Then "i" is increased 1 at a time and so does the number of elements in the array. I believe that the array a(4) and the for loop does something that "remembers" the same numerical value not to be repeated. I'm not sure exactly what the for loop does and how the flag make this thing work.

Lets say, a case where i=1 and the RN=3, the flag becomes false. Therefore, a(1)=3. Then, i increments by 1 and a(j) becomes a(2), which puts out the values 1 and 2. Since both numbers are flag=false, it increments again. Because a(i) = RN, a(2) becomes = 3. How can this be? It has a(1) equal to 3 and a(2) also equal to 3. Each array is supposed to have NON-OVERLAPPING numbers.

The result of doing shuffle() is a random set of numbers that don't overlap:

1234, 1243, 1342, 1324, 2341, 3412, 4321, 3214, and so on.
but never 1111, 1112, 3333 or 3242.

To find out how exactly it works, I tried to delete some lines, tweak the numbers. The result of that is either numbers change to repeats, all zeros or a logical error. The following is the code placed in the module and can be used for other forms and in this case it is used for the labels in form1 windows form:

Sub Shuffle()
Dim a(4), i, j, RN As Integer
Dim flag As Boolean

[code]....

View 2 Replies

Array Shorting, Numbers As Text?

Sep 25, 2011

While split a textline with numbers (integers), i get an array with numbers as string.Is it possible to short them? Array.short does not work as it shorts according the first number of the integer

[Code]...

View 5 Replies

Create An Array Of 10 Random Numbers?

Apr 19, 2011

I have not messed with VB much and I have been trying to do something that has me stumped. I wanted to create an array of 10 random numbers. Each of these numbers then is printed onto a label. From here I have two more labels that show the highest and lowest value. I got the first part, 10 random numbers show up but then things get shaky. This is what I have thus far.

[Code]...

View 1 Replies

Find Consecutive Numbers In An Array?

Oct 31, 2011

I need to find consecutive numbers in an array and return a string which tells the range and numbers that don't form a range.I found some of the already asked questions but none of them is in VB.Net:Add to array consecutive numbersIf the array of numbers looks like {11,12,67,68,69,70,92,97} then returned string should be of the form 11,12, 67 through 70, 92 and 97.

View 1 Replies

Find Duplicate Numbers From An Array?

Sep 22, 2009

I am having trouble in finding duplicate numbers in an array.the first one is to create an array with duplicates and then display the number that has been duplicated and how many times it has been duplicated.

Here is my uncompleted code:

Dim arry(4) As Double
arry(0) = 4
arry(1) = 44

[code]....

View 14 Replies

Find The Mode Of An Array Of Numbers?

May 6, 2010

how do i find the Mode of an array of numbers.this is what i have so far, sacount1 is the max index

For j = 1 To SAcount1
If NFAI(j) = NFAI(j - 1) Then
x1 = x1 + 1[code].....

View 14 Replies

Generate Random Numbers In An Array?

Feb 3, 2011

Generating random numbers in an array HELP

View 6 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved