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
System.TextImports
System.SecurityImports
System.Security.CryptographyModule
App
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()
rng.GetBytes(buff)
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
Console.WriteLine(sb)
Console.ReadLine()
End Sub 'MainEnd Module
Then save and close notepad.
Compile the code:
vbc code.vb
Execute the code:
code 128
code 64
Voila!!
Leave a Reply