Implementing a project with VB Script. I'm stuck. Can someone help me?

I've applied for an IT specialist training program for application development and now have a trial project to work on. Unfortunately, I'm stuck, and after trying almost everything else, I'm looking for help here. Here's my task:

"Create a program that writes a fixed number of random numbers to a file.

Create the program as a VB script.

The random numbers should be written to the file as binary data . The program should initially request user input regarding how many bytes of random numbers should be written to the file. The name and location of the file should be stored as a constant in the program.

Check the contents of the file created by the program with a hexadecimal editor . Make sure the numbers were written to the file as binary data, not text. The individual bytes in the file must contain random values ​​in the range 0x00 to 0xFF.

To check, count the number of occurrences of each value in the created file by extending your program.

For a random number file with 100,000 bytes, each byte should occur on average about 390 times.

Output a list of values ​​and their counts to a separate text file."

I have already tried to find out more and have also downloaded a hexadecimal editor (HxD).

If anyone knows the best way to proceed or can help me with this task, that would be a great relief. Unfortunately, I really don't know what to do next.

Many thanks in advance!

 

(1 votes)
Loading...

Similar Posts

Subscribe
Notify of
6 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Erzesel
1 year ago

I have no idea why anyone today is still relying on VBScript.

The language has not been further developed since 2009 and is being shortened completely disappear from the system . To use them today is bordered by morgue!

and search now

…you can look a long way

Classic VBScript is only capable with a lot of trickery/use.

VBScript does not know bytearray or binary files! You can work with "remote objects" like ADODB.Stream, which naturally presupposes that these are also present in the system.

For emergency, a string can be used as a container for individual bytes/charas. fill these with the desired number of random ASCII characters from 0 to 255 and then write them into a file.

…so I'll whistle the body…

create_random_bin_file.vbs

 Input = InputBox("Enter number of Bytes to write") 'ich verzichte auf einen Check ob der Input eine Zahl ist Dim arrReportBytes(255) 'array zum zählen des auftretens der einzelnen zufälligen Werte Dim myBinaryString 'fake ByteArray Dim byteValue 'mit 0en füllen... For n=0 To 255 arrReportBytes(n) = 0 Next 'los gehts... Randomize For n=1 To Input  byteValue = int(Rnd*( &H0FF +1)) 'zufälliger Wert von 0 bis 255 (0x0FF) !!!cint()/clong() runden falsch!!! int() rundet ab, darum +1)  myBinaryString = myBinaryString & Chr(byteValue) 'hänge das ASCII-Zeichen mit dem Wert an den String an  arrReportBytes(byteValue) = arrReportBytes(byteValue) +1 'zähle das Auftreten des Wertes Next Set FS = CreateObject("Scripting.FileSystemObject") Set TextStream = FS.CreateTextFile("test.binary") 'schreibe das so erzeugte falsche "Array" TextStream.Write myBinaryString TextStream.Close Set ReportFile = FS.CreateTextFile("Report.txt") For n=0 To 255 ReportFile.WriteLine "Wert: 0x" & Hex(n) & " existiert " & arrReportBytes(n) & " mal." Next ReportFile.Close MsgBox("Fertich...")
Suiram1
1 year ago

The first step would be Documentation to look over. At Visual Basic you even have the luxury that this is available in German.

In itself, the procedure is very simple. First, of course, it is necessary to read how many random numbers are to be generated. On the basis of the number read in, I would like to Array Type byte create with the given capacity. Well, I’d be in one For loop (here apparently called ‘For…Next’) the array with Random figures fill. In the next step, of course, the generated random numbers written to the file ,. That was already and as you can see, you can find everything in documentation or Google search.

Supplement: Since you’ve noticed that you’ve never worked with Visual Basic, you should also look at how to create an application at all (must make sure you choose not C# but Visual Basic).

However, it is necessary to note that bizarre mentions Visual Basic really is no longer timely and even if it is a test task it is not much sense to use Visual Basic.

lg Suiram1

Erzesel
1 year ago
Reply to  Suiram1

that should be VBScript and not VB.Net that is a huge difference. VBScript does not know any data types and does not even know an array of type Byte

Suiram1
1 year ago
Reply to  Erzesel

Thanks for the hint.