Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17
  1. #16
    Hassan's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    System.Threading.Tasks
    Posts
    4,764
    Reputation
    495
    Thanks
    2,133
    My Mood
    Dead
    Quote Originally Posted by aLcohoL_95 View Post


    im not talking about its easy or hard
    im talking about is it possiblie or impossible

    so its %100 possible
    but not easy as u said
    and i think its easier then compiling code with mscvr.dll :P
    I know, I know. I was just saying ;[

  2. #17
    cosconub's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    in the programming section MPGH Cash: $90,000,000,000
    Posts
    372
    Reputation
    -4
    Thanks
    39
    My Mood
    Psychedelic
    Code:
    Imports System.CodeDom.Compiler

    x2 Textbox (Textbox1.text & Textbox2.text)
    x1 Button (Button1)

    Code:
    Dim CompilePath As String
    
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      Dim FileSave As New SaveFileDialog 'Declares a save file dialog so the user can specify where to save the compiled file.
    Call CompileCode()
      With FileSave
        .InitialDirectory = Application.StartupPath 'Sets initial directory to the startup path of the application.
    
        .FileName = "*.exe"
        .DefaultExt = ".exe|*.exe"
      End With
    
      If FileSave.ShowDialog = Windows.Forms.DialogResult.OK Then
        CompilePath = FileSave.FileName
      Else : Exit Sub 'If the user hits cancel/'X', we exit the sub.
      End If
        End Sub
    
    Sub CompileCode()
      Dim TheCode As String = TextBox1.Text 'Stores the written code in the 'TheCode' variable.
      CreateEXE(CompilePath, TheCode) 'Calls the function to Compile the code, with "CompilePath" as the location for the code to be compiled to, and "TheCode" as the code to be compiled.
        End Sub
    Sub CreateEXE(ByVal SaveLocation As String, ByVal Code As String)
      On Error Resume Next 'To Avoid exceptions being thrown.
    
      Dim Settings As New CompilerParameters() 'To store the settings of our compiler in.
      Dim Compiler As ICodeCompiler = (New VBCodeProvider).CreateCompiler 'Declaring our compiler.
    
      With Settings 'Setting some Settings for the compiler.
        .GenerateExecutable = True
        .OutputAssembly = SaveLocation 'Sets save location to the place the user inputed in the FileSave.sfd
        .CompilerOptions = "/target:winexe" 'Tells the compiler to compile the code as a winexe file.
        .ReferencedAssemblies.Add("System.dll") 'Imports System
      End With
    
      Code = Code.Replace("[*message*]", TextBox2.Text) 'Replaces the place holder for the message box's message with the message that was entered in textbox2.text
      Compiler.CompileAssemblyFromSource(Settings, Code) 'Compiles the code with all the settings stored in the "Settings" string.
        End Sub

    A man is but the product of his thoughts what he thinks, he becomes.
    ~Mohandas Gandhi


    A Genius is nothing with out an idea, An idea is always an idea even without a genius.
    ~ Immortal

Page 2 of 2 FirstFirst 12