[Tutorial] [VB.Net] Making a Builder and Stub Program 01-11-2011, 07:33 PM
#1
VB.Net Tutorial - Making a Builder and Stub using IO.File operations
Contents:
- Introduction
- Form Design
- Coding
Introduction
A User-generated application, or a builder and a stub combination is mainly used when you need userinputs in a new PC whose user does not have any idea what that app may do.
There are three names used in Builder-stub system for applications:
- Builder
- Stub
- Server (or Output)
Builder is the application a User operates and inputs his info which is used by Stub.
Stub is the application which should NOT even be touched by the User. Builder uses the Stub to give an Output, a new application commonly known as "Server".
Server is the final output. Ready to spread.
Why should I keep stub?
Your output is >90% Stub
This is how it goes:
Stub Application + User Settings = Server Application
Form Design
This is the easiest and the shortest part.
What do you need?
- Visual Basic .Net Beginner knowledge
- Some time.
- And of course, Visual Studio for working in Visual Basic .Net
In this Tutorial, we will make 2 Programs: Builder and Stub
Builder:
![[Image: builder.png]](http://g.imagehost.org/0694/builder.png)
Controls needed:
- TextBox = 2
- Button = 1
![[Image: stub.png]](http://j.imagehost.org/0660/stub.png)
No controls needed.
In fact, you don't even need a Form, you can just use a Class Module if you know how to, otherwise don't worry Form will do ok.
Coding
Now comes the hardest part, but I would also add, the more interesting part.
In your Builder form enter this code.
Quote:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim theStub As String = CurDir() & "\stub.exe" 'Stub should be in Builder's Directory
If IO.File.Exists(theStub) = False Then 'If it's not then
MsgBox("No Stub Found", MsgBoxStyle.Exclamation) 'display a message
Exit Sub 'and Exit the rest of the Sub
End If
IO.File.Copy(theStub, CurDir() & "\server.exe") 'Copy stub as Server
IO.File.AppendAllText(CurDir() & "\server.exe", "FileSplit" & TextBox1.Text & "FileSplit" & TextBox2.Text) 'Add user-settings to Server with a FileSplit
End Sub
Great you are half-way there!.
Now enter this code in your Stub form:
Quote:Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim BinText As String = IO.File.ReadAllText(Application.ExecutablePath) 'Read All Text in Itself and store in variable BinText
If BinText.Contains("FileSplit") = False Then Exit Sub 'If there is the same Builder's FileSplit then
Dim ArrContents() As String = Split(BinText, "FileSplit") 'Store BinText splitted by FileSplit
For num As Integer = 1 To UBound(ArrContents) 'Loop through each element in ArrContents except 0, which is useless for us here
MsgBox(ArrContents(num)) 'Show a MessageBox for the UserInputted Text in Builder
Next
End Sub
Well done, you are done with both.
Now build them, put them in same directories, and test the Builder.
![Smile Smile](https://sinister.ly/images/smilies/set/smile.png)
Have a great day. :thumbs:
![[Image: rytwG00.png]](http://i.imgur.com/rytwG00.png)
Redcat Revolution!