Cześć
Mam pytanie czy ktoś mógłbym poprawić kod tak żeby składnia kodu była poprawna bo mam pewien problem z tym.
Kod:
Imports Microsoft.VisualBasic
Imports System.CodeDom.Compiler
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Module Module1
Sub Main()
Dim kod As String = "Imports System" & vbNewLine & "Module Module1" & vbNewLine & "Sub Main()" & vbNewLine & "Console.WriteLine(" & Chr(34) & "abc" & Chr(34) & ")" & vbNewLine & "Console.ReadKey()" & vbNewLine & "End Sub" & vbNewLine & "End Module"
If (Skompiluj(kod, "program.exe")) Then
Process.Start("program.exe")
Else
MsgBox(kod)
End If
End Sub
Function Skompiluj(ByVal kod As String, ByVal nazwa As String)
Dim vb As New VBCodeProvider
Dim icc As ICodeCompiler = vb.CreateCompiler()
Dim parametry As New CompilerParameters
parametry.GenerateExecutable = True
parametry.OutputAssembly = nazwa
Dim wynik As CompilerResults = icc.CompileAssemblyFromSource(parametry, kod)
Return wynik.Errors.Count = 0
End Function
End Module
End Sub
End Class
może pytanie dziwne ale naprawdę nie wiem jak to powinno być.