Showing posts with label functions. Show all posts
Showing posts with label functions. Show all posts

Sunday, 23 September 2012

MDI form in vb.net

In this tutorial I’m going show how use MDI form in visual basic. This is in contrast to single document interface (SDI) applications, which can manipulate only one document at a time. You can more than on document in MDI form.Visual Studio Environment is an example of Multiple Document Interface (MDI) and notepad is an example of an SDI application, opening a document closes any previously opened document. Any windows can become an MDI parent, if you set the IsMdiContainer property to True.
IsMdiContainer = True The following vb.net program shows a MDI form with two child forms. Create a new VB.Net project, and then you will get a default form Form1. Then add two more forms in the project (Form2, Form 3). Create a Menu on your form and call these two forms on menu click event. Click the following link to see how to create a Menu on your form
Public Class Form1
 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 IsMdiContainer = True
 End Sub
 Private Sub MenuItem1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1ToolStripMenuItem.Click
    Dim frm2 As New Form2
    frm2.Show()
    frm2.MdiParent = Me
  End Sub
  Private Sub MenuItem2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2ToolStripMenuItem.Click
    Dim frm3 As New Form3
    frm3.Show()
    frm3.MdiParent = Me
  End Sub
End Class

Thursday, 16 August 2012

functions in vb.net

In this tutorial, we cover the Function and how it works. Similar to the sub procedure, a function is also a method which stores code to be executed when called. The difference is a function returns a value where a sub procedure doesn’t. When merging more than one code block simply call function name and pass arguments. Copy and paste below Code:
Public Class Form1
Dim labeltext As String = "functions are cool lol"
Private Function changelabeltext()
Return labeltext
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = changelabeltext()
End Sub
End Class

Saturday, 28 January 2012

How to use functions in vb.net?


How to use functions in vb.net?
We can use functions for return the value in function block into main block of code. This tutorial shows how to use the functions in vb.net?
Step1:
Open Microsoft visual studio
Step2:
Select file newàwindows form application à rename it as functions
Step3:
Drag and drop the button, label
Step4:
Double click the button and write the code
Code:
Public Class Form1

    Private SubButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.Click

        Label1.Text = callthefunction()

    End Sub

    Private Functioncallthefunction()

        callthefunction = "your so...cool"

    End Function

End Class
  Output: