arrays

Join arrays in VB.net

What's the simplest way to join one or more arrays (or ArrayLists) in Visual Basic? I'm using .NET 3.5, if that matters much. ...

Finding Min and Max Vaules In an array using vb.net

Hey, I need to find the min and max vaule on an array. The .max function works but .min keeps showing zero. Public Class Program_2_Grade Dim max As Integer Dim min As Integer Dim average As Integer Dim average1 As Integer Dim grade As String Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As Syst...

In PHP, how can I correct missing keys in an array?

After using array_unique, an array without the duplicate values is removed. However, it appears that the keys are also removed, which leaves gaps in an array with numerical indexes (although is fine for an associative array). If I iterate using a for loop, I have to account for the missing indexes and just copy the keys to a new array, b...

Most efficient way to convert an HTMLCollection to an Array

Is there a more efficient way to convert an HTMLCollection to an Array, other than iterating through the contents of said collection and manually pushing each item into an array? ...

VB.Net error: Index was outside the bounds of the array

This error comes out whenever I clicked the datagrid. Program does fill the datagrid every time data was selected in the combobox. For example: I choose data1 which has 4 records in datagrid. then I click row index no 1. No problem will shown but when I choose again another data in combobox, for example: Data 2 has only 1 record then ...

How to compare two arrays and remove matching elements from one for the next loop?

How else might you compare two arrays ($A and $B )and reduce matching elements out of the first to prep for the next loop over the array $A? $A = array(1,2,3,4,5,6,7,8); $B = array(1,2,3,4); $C = array_intersect($A,$B); //equals (1,2,3,4) $A = array_diff($A,$B); //equals (5,6,7,8) Is this the simplest way or is there a way to ...

Is there a PHP function to remove any/all key/value pairs that have a certain value from an array?

I think questions like this are the reason why I don't like working with PHP. The manual is good, if you can find what you are looking for. After reading through the Array Functions, I didn't see one that provides the functionality I need. I have an array (in my case, numerically indexed) that I want to scan for a particular value and, ...

API java 5 and more: should I return an array or a Collection ?

In the spirit of Best Practices: Always return a ____, never a ____, I face a similar question in my upcoming migration from JDK1.4.2 to JDK5 and more. (Yes, I know, JDK1.4.2 is EOL! ;-) ). For functions returning a collection (which are not simple property collections), I always prefer (in JDK1.4.2) returning an Array instead of a gene...

PowerShell array initialization

What's the best way to initialize an array in Powershell? For example the code $array = @() for($i=0; $i -lt 5;$i++) { $array[$i] = $FALSE } generates the error Array assignment failed because index '0' was out of range. At H:\Software\PowerShell\TestArray.ps1:4 char:10 + $array[$ <<<< i] = $FALSE ...

Convert Byte Array to Integer In VB.Net

I'm wonder what the best way to convert a byte array (length 4) to an integer is in vb.net? I'm aware of BitConverter, but it seems like quite a waste to do a function call to do something that should be able to be done by copying 4 bytes of memory. Along the same lines, what about converting a single/double from it's binary representat...

array compiling from mysql help required.

Hi This has been bugging me, I can't get my head around it. I will use the foodstuffs analogy to try and simplify my probelm. 1000 members of the public where asked to pick a variety from each of 13 categories of footstuff. These selections were then stored in a mysql database against their name. e.g. billy mary etc. etc. mi...

Fortran Array to C array. Stupid macro tricks wanted

I have this 'simplified' fortran code real B(100, 200) real A(100,200) ... initialize B array code. do I = 1, 100 do J = 1, 200 A(J,I) = B(J,I) end do end do One of the programming gurus warned me, that fortran accesses data efficiently in column order, while c accesses data efficiently in row order. He suggested that I t...

Converting a byte() array to a double in VB.Net

Hi, I have this situation. I have a real stored in a varbinary field in a sql 2005 database. As I can't convert a varbinary to a real in sql 2005, I'm trying to do that in vb.net. That field gets stored as a byte() array in a DataTable. Now I would like to read that byte() into a double, or decimal variable. But I don't have much of a ...

Why this code is not working ?

Hi guys I wrote this code and i have two errors. Invalid rank specifier: expected ',' or ']' Cannot apply indexing with [] to an expression of type 'int' Can you help please? static void Main(string[] args) { ArrayList numbers = new ArrayList(); foreach (int number in new int[12] {10,9,8,7,6,5,4,3,2,1}) //...

So you think you know pointers?

I was shown this recently, and thought this was a really cool piece of code. Assume 32-bit architecture. #include <stdio.h> int main(void) { int x[4]; printf("%p\n", (void*) (x)); printf("%p\n", (void*) (x + 1)); printf("%p\n", (void*) ( printf("%p\n", (void*) ( } Without compiling the program, what does it output...

How do I sort a two-dimensional array in C#?

I have a two-dimensional array (of Strings) which make up my data table (of rows and columns). I want to sort this array by any column. I tried to find an algorithm for doing this in C#, but have not been successful. Any help is appreciated. ...

Dynamic Arrays

I'm just starting to learn C++ so excuse me for this simple question. What I'm doing is reading in numbers from a file and then trying to add them to an array. My problem is how do you increase the size of the array? For example I thought might be able to just do: #include <iostream> using namespace std; int main() { double *x; ...

What's the best way to extract a one-dimensional array from a rectangular array in C#?

Say I have a rectangular string array (stringarray[rows, columns] - not a jagged array). What's the best way to extract a one-dimensional array from this (either a single row or a single column)? I can do this with a for loop, of course, but I'm hoping .NET has a more elegant way built in. Bonus points for converting the extracted str...

Enhancing Profile Provider

Hi, I am want to serialize and array object for a custom wizard I am writing but I am having difficulties doing this. Can someone help this is the error and code snippets I am using. The error I believe has to do with not being able to convert the array. namespace Helios.Web.Framework { /// <summary> /// Summary description fo...

How do I sum up weighted arrays in PHP?

Hod do I multiply the values of a multi-dimensional array with weigths and sum up the results into a new array in PHP or in general? The boring way looks like this: $weights = array(0.25, 0.4, 0.2, 0.15); $values = array ( array(5,10,15), array(20,25,30), array(35,40,45), ...