473,326 Members | 2,104 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,326 software developers and data experts.

passing an Array to a search function - ?

getting a bit stuck here

got some code that allows a user to input numbers to a 3x3 array. but next on the tutorial sheet i have to then ask the user for a number to search for and then search the array for that number and come back with its location in the array

now i have the code that fils the array, but i dont know how to write the function, or what i should be passing to the function. i dont know how to get a location out of the other end either! :(

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub cmdT5d_Click()
  3.  
  4. Dim intCol As Integer
  5. Dim intRow As Integer
  6. Dim intMyArray(3, 3) As Integer
  7. Dim intFindNum As Integer
  8. Dim intNumSearch As Integer
  9.  
  10.  
  11.  
  12.  
  13.  
  14. For intRow = 1 To 3
  15. For intCol = 1 To 3
  16.  
  17. intMyArray(intRow, intCol) = InputBox("please enter numbers into the array", "Numerical Input Box", 1)
  18.  
  19. Next intCol
  20. Next intRow
  21.  
  22. FindNum = InputBox("please select a number to search for","number search",1)
  23.  
  24.  
  25. NumSearch = Lsearch(intMyArray(), intFindNum)
  26.  
  27. txtT5e.text = NumSearch
  28.  
  29. End Sub
  30.  
for the search function then is this correct?
Expand|Select|Wrap|Line Numbers
  1. Private Function Lsearch(intMyArray() As Integer, intFindNum As Integer) As Integer 
  2.  
thats as far as i got :(
Oct 31 '07 #1
3 1418
Killer42
8,435 Expert 8TB
Your search function declaration looks pretty good to me. The code in there will just need to do a couple of nested loops like the ones that filled the array, and test whether each entry matches the search value.
Nov 1 '07 #2
cheers dude,

erm would i need to pass intCol and intRow through or would it already know about those?
Nov 1 '07 #3
QVeen72
1,445 Expert 1GB
Hi,

Declare the array at the Form-Level..(Top of Form's Code Window)
So that, When you write the Search Code in another Command_Click, the array is still there..
If you declare in command_Click, the array goes out of scope...


Regards
Veena
Nov 1 '07 #4

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

Similar topics

12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
8
by: kalinga1234 | last post by:
there is a problem regarding passing array of characters to another function(without using structures,pointer etc,).can anybody help me to solve the problem.
11
by: deko | last post by:
I need to create a basic one-dimensional array of strings, but I don't know how many strings I'm going to have until the code is finished looping. pseudo code: Dim astrMyArray() Do While Not...
11
by: John Pass | last post by:
Hi, In the attached example, I do understand that the references are not changed if an array is passed by Val. What I do not understand is the result of line 99 (If one can find this by line...
2
by: Mark Drummond | last post by:
Hi all. I've been using Perl for many years now, but I am a "use it and learn it as you need it" type. I having some trouble passing a list to the "search" subroutine from Net::LDAP. I am trying...
4
by: assgar | last post by:
Hi I am stuck on a problem. I use 3 scripts(form, function and process). Development on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. The form displays...
0
by: kencana | last post by:
hi All, I got problem in passing data (more than one) from soap client to the soap server. but if i only passing one data at a time, it works successfully.. The following is the error message i...
7
by: =?Utf-8?B?YmVyaWNr?= | last post by:
New to this, I used to pass an array like this function BytesToString(byref myarray() as byte, somethingelse as long) as long and m = BytesToString(fooBar(), bluenose) This would send...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.