Core
02-12-2010, 08:28 PM
What are the library files
library files usually defines as .DLL and it's a way to make a part of programming codes to future using ,after that all you have to do is just refer the library file and insert the input and eventually you can get the output from library file
like make a cake you insert the cake to oven and finally you get out a baked cake so in here the oven acts as a library file
Advantages of using Library files
You don't need to type codes so much ,once you made a library file for special part ,like (basic arithmetic calculation )then you may need to insert the first_value and second_value to the library file and finally you can get the answer from the library file so it's the answer of above two values
also you can use it in different languages ,assume you made a .DLL file in VB.nET then you can also use it under any Microsoft (but same CLR version (.NET version)) languages which come along with Visual Studio package
Way to make Library Files
In this example I am going to perform some basic arithmetic operation
First make a new project
Select Class Library as your project type
Now you can see there is almost nothing just spaces with few lines
Now add the following codes
'///////////The .DLL (Class Library File)
'********************************************
Public Class Arithmetic_Operation
'//all codes were written by Core(myself) and belong to Core so don't steal this shit
'//reposting , copy paste doesn't matter but need to put the reference first
Dim _firstValue ,_secondValue ,_answer as Double
Dim _symbol as String
Public Function calculate(ByVal firstValue , ByVal secondValue ,ByVal symbol ) as Double
Select case symbol
case "+"
answer = Val(firstValue) + Val(secondValue)
case "-"
answer = Val(firstValue) - Val(secondValue)
case "/"
answer = Val(firstValue) / Val(secondValue)
case "*"
answer = Val(firstValue) * Val(secondValue)
case ""
MsgBox("error Message")
End Select
Return answer
End Function
End Class
'********************************************
the main form
------------------------
Import DLLNAME.Arithmetic_Operation
Public Class MainForm
Dim _firstValue ,_secondValue Double
Dim _symbol as String
Dim _dll_file as new DLLNAME
'//add button
Public Sub btn_add(ByVal sender as Object,ByVal e as System.EventArgs)Handler btn_add.Click
_firstValue = TextBox.Text '//get the value from textbox(user typed value
'//to firstValue variable)
_symbol = "+" '//symbol represents what to do (it may useful in equal '//button because we have only one equal button)
TextBox.Clear() '//clear the textbox to type to second value
'// 1 + 2 = 3 ('//first you type 1 then + then 3 then finally = )
'('//first you type 1 then + then 3 then finally = )
'when you type the value 1 then display box (textbox shows it on itself)
'then you type one of operator keys (because anyone can type any 'operator it doesn't matter first + ,- ,* ,/ so symbol is needed to determine
'which operator key was clicked finally clear the textbox to type to second 'value
End Sub
'//subtract button
Public Sub btn_subtract (ByVal sender as Object,ByVal e as System.EventArgs)Handler btn_subtract .Click
_firstValue = TextBox.Text
_symbol = "-"
End Sub
'//multiply button
Public Sub btn_multiply (ByVal sender as Object,ByVal e as System.EventArgs)Handler btn_multiply.Click
_firstValue = TextBox.Text
_symbol = "*"
End Sub
'//divide button
Public Sub btn_add(ByVal sender as Object,ByVal e as System.EventArgs)Handler btn_divide.Click
_firstValue = TextBox.Text
_symbol = "/"
End Sub
Public Sub btn_equal(ByVal sender as Object,ByVal e as System.EventArgs)Handler btn_equal.Click
'insert the input values to the DLLNAME.Arithmetic_Operation's(DLL file) 'calculate method and that method finally return the answer to its name 'so 'all you have to do is just refer its name with insert values ,it will return the
'answer eventually so that value pass over to the display (in here TextBox's .Text Property because only values show on that pass to .Text property)
_secondValue = TextBox.Text '//get the second value and pass to second 'Value variable
TextBox.Text = Val(_dll_file.calculate(_firstValue,_secondValue,_ symbol))
'//the Val(as String)as Double method returns any values contains in any string variable
End Sub
End Class
NOTE
if I have done anything wrong then plz tell me I am bored to test this out anyway don't copy and paste because this format is not suitable and there should be done some modifications but basically coding goes like this way
remember to use ' ' for comments to comment out my texts
library files usually defines as .DLL and it's a way to make a part of programming codes to future using ,after that all you have to do is just refer the library file and insert the input and eventually you can get the output from library file
like make a cake you insert the cake to oven and finally you get out a baked cake so in here the oven acts as a library file
Advantages of using Library files
You don't need to type codes so much ,once you made a library file for special part ,like (basic arithmetic calculation )then you may need to insert the first_value and second_value to the library file and finally you can get the answer from the library file so it's the answer of above two values
also you can use it in different languages ,assume you made a .DLL file in VB.nET then you can also use it under any Microsoft (but same CLR version (.NET version)) languages which come along with Visual Studio package
Way to make Library Files
In this example I am going to perform some basic arithmetic operation
First make a new project
Select Class Library as your project type
Now you can see there is almost nothing just spaces with few lines
Now add the following codes
'///////////The .DLL (Class Library File)
'********************************************
Public Class Arithmetic_Operation
'//all codes were written by Core(myself) and belong to Core so don't steal this shit
'//reposting , copy paste doesn't matter but need to put the reference first
Dim _firstValue ,_secondValue ,_answer as Double
Dim _symbol as String
Public Function calculate(ByVal firstValue , ByVal secondValue ,ByVal symbol ) as Double
Select case symbol
case "+"
answer = Val(firstValue) + Val(secondValue)
case "-"
answer = Val(firstValue) - Val(secondValue)
case "/"
answer = Val(firstValue) / Val(secondValue)
case "*"
answer = Val(firstValue) * Val(secondValue)
case ""
MsgBox("error Message")
End Select
Return answer
End Function
End Class
'********************************************
the main form
------------------------
Import DLLNAME.Arithmetic_Operation
Public Class MainForm
Dim _firstValue ,_secondValue Double
Dim _symbol as String
Dim _dll_file as new DLLNAME
'//add button
Public Sub btn_add(ByVal sender as Object,ByVal e as System.EventArgs)Handler btn_add.Click
_firstValue = TextBox.Text '//get the value from textbox(user typed value
'//to firstValue variable)
_symbol = "+" '//symbol represents what to do (it may useful in equal '//button because we have only one equal button)
TextBox.Clear() '//clear the textbox to type to second value
'// 1 + 2 = 3 ('//first you type 1 then + then 3 then finally = )
'('//first you type 1 then + then 3 then finally = )
'when you type the value 1 then display box (textbox shows it on itself)
'then you type one of operator keys (because anyone can type any 'operator it doesn't matter first + ,- ,* ,/ so symbol is needed to determine
'which operator key was clicked finally clear the textbox to type to second 'value
End Sub
'//subtract button
Public Sub btn_subtract (ByVal sender as Object,ByVal e as System.EventArgs)Handler btn_subtract .Click
_firstValue = TextBox.Text
_symbol = "-"
End Sub
'//multiply button
Public Sub btn_multiply (ByVal sender as Object,ByVal e as System.EventArgs)Handler btn_multiply.Click
_firstValue = TextBox.Text
_symbol = "*"
End Sub
'//divide button
Public Sub btn_add(ByVal sender as Object,ByVal e as System.EventArgs)Handler btn_divide.Click
_firstValue = TextBox.Text
_symbol = "/"
End Sub
Public Sub btn_equal(ByVal sender as Object,ByVal e as System.EventArgs)Handler btn_equal.Click
'insert the input values to the DLLNAME.Arithmetic_Operation's(DLL file) 'calculate method and that method finally return the answer to its name 'so 'all you have to do is just refer its name with insert values ,it will return the
'answer eventually so that value pass over to the display (in here TextBox's .Text Property because only values show on that pass to .Text property)
_secondValue = TextBox.Text '//get the second value and pass to second 'Value variable
TextBox.Text = Val(_dll_file.calculate(_firstValue,_secondValue,_ symbol))
'//the Val(as String)as Double method returns any values contains in any string variable
End Sub
End Class
NOTE
if I have done anything wrong then plz tell me I am bored to test this out anyway don't copy and paste because this format is not suitable and there should be done some modifications but basically coding goes like this way
remember to use ' ' for comments to comment out my texts