Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleBuild a random ASCII text file for testing data transfer rates
KeywordsASCII, random, data file, test file
CategoriesTips and Tricks, Files and Directories
 
Thanks to Kenneth Ives.

The program does some work to calculate the size of the file it should build and to insert carriage returns. The main piece is the following code that generates a random printable ASCII character. See the code for additional details.

 
' Create the random printable characters
' (ASCII value between 33 and 126 inclusive)
iChar = 33 + Int(Rnd * (126 - 33 + 1))
sChar = Chr(iChar)
sTmpRec = sTmpRec & sChar

' If the temporary string is 78 characters
' long then append it to the final output
' string
If Len(sTmpRec) = 78 Then
    sOutRec = sOutRec & sTmpRec
    sTmpRec = ""
End If

' Increment the Byte and column counters
lByteCnt = lByteCnt + 1
lCnt = lCnt + 1

iChar = Int(Rnd * 125) + 1
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated