473,394 Members | 1,932 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,394 software developers and data experts.

i want to generate a matrix of 0's and 1's which is random every time plz hlp...!!

i want to generate a series of random numbers like

00101
01011
01111
01010
11101

it is a 5*5 matrix and is random every time upon execution
my code is:-


Private Sub Command1_Click()

Call Randomize
Dim x As Integer, y As Integer, z As Integer, t As Integer, s As Integer
Dim i As Integer, k As Integer
x = 0 + Int(2 * Rnd())

y = 0 + Int(2 * Rnd())

z = 0 + Int(2 * Rnd())
t = 0 + Int(2 * Rnd())

s = 0 + Int(2 * Rnd())
Print x, y, z, t, s

End Sub

but i have to click on command button each time to generate a random 0's and 1's and i want to print random 5*5 matrix in a single click as said above but in this code when i m clicking the command button i m getting a 1*5 random matrix and i have to click again and again.....can i use goto control and send the cursor to initialize again and again and print till i get a 5*5 matrix or use for loop.. but i have tried everything and it isn't working....please help me get 5*5 random matrix of 0's and 1's.......
Nov 7 '09 #1
1 2020
vb5prgrmr
305 Expert 100+
Use a nested for loop structure...
Expand|Select|Wrap|Line Numbers
  1. Dim OuterForLoopCounter As Integer, InnerForLoopCounter As Integer
  2. Dim Result As Integer, MyMatrix(1 To 5, 1 To 5) As Integer
  3. For OuterForLoopCounter = 1 To 5
  4.   For InnerForLoopCounter = 1 To 5
  5.     Result = Int(2 * Rnd)
  6.     MyMatrix(OuterForLoopCounter, InnerForLoopCounter) = Result
  7.   Next InnerForLoopCounter
  8. Next OuterForLoopCounter
  9.  


Good Luck
Nov 8 '09 #2

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

Similar topics

6
by: Acacia | last post by:
How would you generate a random number in C++?
11
by: Zeya | last post by:
I need to randomly generate a 16 digit hex number in C# code. How can I do this? Thanks.
14
by: amitnanda | last post by:
Hi Guys, I have a matrix multiplication program in C that multiplies two matrices. When their size is 3*3 or 800*800, the program runs fine. But above that size, I get a "segmentation fault"....
6
by: comp.lang.php | last post by:
/** * Generate the random security image * * @access public * @param $willUseFilePath (default false) boolean to determine if you will be using a file path * @param mixed $filePath (optional)...
21
by: =?UTF-8?B?TWFydGluIFDDtnBwaW5n?= | last post by:
Hello, I´m using a very large 2-dimensional double matrix (45.000x45.000) in my program. At the initialization of the matrix: double matrix = new double I am getting an out of memory...
232
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first...
20
by: jjmillertime | last post by:
I'm new so i apologize if this is in the wrong spot. I'm also new to programming in C and i've been searching for quite a while on how to create a program using C that will generate two random...
24
by: pereges | last post by:
I need to generate two uniform random numbers between 0 and 1 in C ? How to do it ? I looked into rand function where you need to #define RAND_MAX as 1 but will this rand function give me ...
1
by: Sozos | last post by:
Hi guys. I have a problem with writing the base case for the following matrix multiplication function I have implemented. Please help. #define index(i,j,power) (((i)<<(power))+(j)) void...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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...

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.