473,473 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Fill up string array with random characters?

Let's say I declares an array of string (of size 1000),
how to fill every elements of it with random characters?

Dim myStrArray(999) As String
...

Thanks...

--
Pedestrian, Penang.

Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200608/1

Aug 15 '06 #1
3 3120
Hello pedestrian via DotNetMonster.com,

Create an array of the characters you want to fill from. Then check out
the Ssytem.Random class.

-Boo
Let's say I declares an array of string (of size 1000), how to fill
every elements of it with random characters?

Dim myStrArray(999) As String
..
Thanks...

Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200608/1

Aug 15 '06 #2
Pedestrian, Penang
In addition to the other comments:

How long do you want each string?

How random do you want each string?

To get random "password" keys (WEP Keys) I will use
RNGCryptoServiceProvider.GetNonZeroBytes:

http://msdn2.microsoft.com/en-us/lib...zerobytes.aspx

Followed by BitConverter.ToString:

http://msdn2.microsoft.com/en-us/library/3a733s97.aspx
If you don't want or need a cryptographically strong sequence of values, you
could use System.Random in a loop. Just remember to create the new
System.Random object outside the loop then call its Next method inside the
loop:

http://msdn2.microsoft.com/en-us/lib...em.Random.aspx

I would use the Random.Next method that accepted a range of values...
passing in Char code points

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"pedestrian via DotNetMonster.com" <u16758@uwewrote in message
news:64c80eac0a1a0@uwe...
| Let's say I declares an array of string (of size 1000),
| how to fill every elements of it with random characters?
|
| Dim myStrArray(999) As String
| ..
|
| Thanks...
|
| --
| Pedestrian, Penang.
|
| Message posted via DotNetMonster.com
| http://www.dotnetmonster.com/Uwe/For...b-net/200608/1
|
Aug 15 '06 #3
Thanks for replying... Mr Jay
I would like to use the strings to insert values to database columns...
such as FirstName, LastName, Address etc.. columns...

Jay B. Harlow [MVP - Outlook] wrote:
>Pedestrian, Penang
In addition to the other comments:

How long do you want each string?

How random do you want each string?

To get random "password" keys (WEP Keys) I will use
RNGCryptoServiceProvider.GetNonZeroBytes:

http://msdn2.microsoft.com/en-us/lib...zerobytes.aspx

Followed by BitConverter.ToString:

http://msdn2.microsoft.com/en-us/library/3a733s97.aspx

If you don't want or need a cryptographically strong sequence of values, you
could use System.Random in a loop. Just remember to create the new
System.Random object outside the loop then call its Next method inside the
loop:

http://msdn2.microsoft.com/en-us/lib...em.Random.aspx

I would use the Random.Next method that accepted a range of values...
passing in Char code points

| Let's say I declares an array of string (of size 1000),
| how to fill every elements of it with random characters?
[quoted text clipped - 3 lines]
|
| Thanks...
--
Pedestrian, Penang.

Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200608/1

Aug 15 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Andreas Lobinger | last post by:
Aloha, i wanted to ask another problem, but as i started to build an example... How to generate (memory and time)-efficient a string containing random characters? I have never worked with...
17
by: JC | last post by:
sorry . i got one more problem i got a string with 4 char. i want to put that in a string with 26 char. how can i fill space on the remain char.. ?? is that i need to do a while loop do fill the...
4
by: Jonathan Burd | last post by:
Greetings everyone, Here is a random string generator I wrote for an application and I'm wondering about the thread-safety of this function. I was told using static and global variables cause...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
10
by: Crirus | last post by:
Is there a function that return some random ID like string alphanumeric? Like this: A35sDsd1dSGsH Thanks Crirus
1
by: Samuel Shulman | last post by:
Any function to randomize strings? thank you, Samuel
12
by: Pascal | last post by:
hello and soory for my english here is the query :"how to split a string in a random way" I try my first shot in vb 2005 express and would like to split a number in several pieces in a random way...
38
by: Andrea | last post by:
Hi, Anyone could me suggest how to create a function that generates a random string? The function should be: int _RandomString(char** str,int len); so, it takes an empty string str and it puts...
14
by: rtillmore | last post by:
Hello, I did a quick google search and nothing that was returned is quite what I am looking for. I have a 200 character hexadecimal string that I need to convert into a 100 character string. ...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
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...
0
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...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.