Compile and execute code on the fly…

A simple way to compile and execute code on the fly. From the cmd console:

notepad code.vb

This opens notepad with a new file called code.vb

Paste in a piece of code, for example:

Imports SystemImports
Sub Main(ByVal argv() As String)

Dim len As Integer = 128

If argv.Length > 0 Then
len = Integer.Parse(argv(0))
End If

Dim buff(len / 2) As Byte
Dim rng As New RNGCryptoServiceProvider()


Dim sb As New StringBuilder(len)
Dim i As Integer

For i = 0 To buff.Length - 1
sb.Append(String.Format("{0:X2}", buff(i)))
Next i


End Sub 'MainEnd Module

Then save and close notepad.

Compile the code:

vbc code.vb

Execute the code:

code 128
code 64


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

A Website.

Up ↑

%d bloggers like this: