473,402 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Help with dynamic arrays

Hello

I am using vba in excel. I am trying to do the following seeing instr is not working I am writing my own program. Just I am having an issue with this
dynamic array.

here is a clip of my code

Expand|Select|Wrap|Line Numbers
  1.     Dim mystring1() As String ' the serial number field
  2.     Dim mystring2() As String 'the data field
  3.  
  4.     Dim searchfield As Integer, searchbyfield As Integer 'hold length of both fields
  5.     searchfield = Len(searchable) 'get the length of the data string"
  6.     searchbyfield = Len(searchby)'get the lenght of the serial number
  7.     ReDim mystring1(searchbyfield) As String
  8. ***I get the followin error with the next line of code. "Can't assignt to array"
  9. searchby is a string past in from the main subroutine.****
  10.     mystring1 = searchby
  11.     ReDim mystring1(searchfield) As String
  12.     mystring2 = searchable
  13.  
any idea's on how to help

Thanks
Feb 10 '06 #1
2 2348
Hi,

I think the problems lies with the a bit of confusion in the variables names used.

Dim mystring1() As String ' the serial number field
Dim mystring2() As String 'the data field

Dim searchfield As Integer, searchbyfield As Integer 'hold length of both fields
searchfield = Len(searchable) 'get the length of the data string"
searchbyfield = Len(searchby)'get the lenght of the serial number
ReDim mystring1(searchbyfield) As String
***I get the followin error with the next line of code. "Can't assignt to array"
searchby is a string past in from the main subroutine.****
mystring1 = searchby
ReDim mystring1(searchfield) As String
mystring2 = searchable
first you creat two arrays 'mystring1 and mystring2', then you re dimension 'mystring1'.

The next step is the confusion you try to place the variable 'searchby' into a variable called 'mystring1' - which is an array without telling where in the array to place it?, thus the confusion.

If you just placed a number in brackets the system would then place it for you. If this is not where it is supposed to go the the variable - NOT the array will have to have its name changed.

I hope this what you are looking for.

Alan Hill
'Blue. Eyes and Soul'
Feb 21 '07 #2
Killer42
8,435 Expert 8TB
What was the original problem with Instr()? Perhaps we can help.
Feb 22 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: John | last post by:
Hi all, I've got an issue with session variables in asp pages. I need to make a decision that I think you can hopefully help me out here. When a session starts on the iss server I need to...
4
by: Vannela | last post by:
How can i achieve the dynamic arrays concept in C#? I have used the ArrayLists of C# but in few cases it is failing like when i pass these dynamic arrays a arguments to functions b'coz in those...
1
by: Geoff | last post by:
I was wondering if anyone could help me with a problem I am having. I am trying to read in a list of numbers from a file and then sort them using pointers and malloc() and free(). I know how to...
2
by: Pasacco | last post by:
dear I want to ask help on this problem. Array a is partitioned into a0 and a1 in main(). Then a1 is partitioned into a2 and a3 in th_partition() function. And I think this problem is something...
4
by: learnfpga | last post by:
Here is a little code I wrote to add the numbers input by the user.....I was wondering if its possible to have the same functionality without using dynamic arrays.....just curious..... ...
23
by: vinod.bhavnani | last post by:
Hello all, I need desperate help Here is the problem: My problem today is with multidimensional arrays. Lets say i have an array A this is a 4 dimensional static array.
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
4
by: hobbes992 | last post by:
Howdy folks, I've been working on a c project, compiling using gcc, and I've reached a problem. The assignment requires creation of a two-level directory file system. No files have to be added or...
2
by: Dr Dav | last post by:
Hello all, I'm a physicist whose rewriting a numerical simulation, previously written in IDL, in C with the goal reducing runtime. As you may imagine, my C programming skills are quite poor but I...
4
by: Sunny | last post by:
Hi, Is there a way in javascript to create Dynamic arrays or arrays on fly. Something Like: var "ptsgN"+sd = new Array(); Here sd is incrementing by 1. I have lots of data that I am...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.