473,607 Members | 2,659 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

passing an Array to a search function - ?

9 New Member
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 1436
Killer42
8,435 Recognized Expert Expert
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
alexmason86
9 New Member
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 Recognized Expert Top Contributor
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
6530
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 courses to pass the correct option value and then be displayed at the following URL: http://www.dslextreme.com/users/kevinlyons/selectResults.html I am passing countries, products, and courses. The first two display
58
10101
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 code... TCHAR myArray; DoStuff(myArray);
8
4107
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
39449
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 rst.EOF i = i + 1 If rst!Something = Then astrMyArray(i) = rst!Something
11
8108
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 number) which is the last line of the following sub routine: ' procedure modifies elements of array and assigns ' new reference (note ByVal) Sub FirstDouble(ByVal array As Integer()) Dim i As Integer
2
4728
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 to pass a list of attributes to be returned by search. The basic method call is: my $searchresults = $ldap->search(OPTIONS) One of the options is "attrs =>" which the documentation describes as "A
4
2704
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 multiple dynamic rows with chechboxs, input box for units of service, description of the service and each row has its own dropdown list of unit fees that apply.
0
2409
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 get when i pass more than one data: "SoapFault exception: looks like we got no XML document in C:\Program Files\MapGuideOpenSource\WebServerExtensions\www\phpviewersample\clienttry2.php:24 Stack trace: #0 : SoapClient->__call('getMap', Array) #1...
7
1729
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 the descriptor or pointer to the array to the function
0
7987
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8472
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8324
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6805
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5471
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3954
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4015
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1318
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.