0% found this document useful (0 votes)
23 views

Vbnet

Uploaded by

tanuj112848
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Vbnet

Uploaded by

tanuj112848
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Window Graphical Interface Elements o Descrip on: Provides instance methods for file opera ons and file

o Descrip on: Provides instance methods for file opera ons and file proper es.
1. Window: o Example: fileInfo.Length
o Descrip on: The main container for an applica on's UI, typically with a tle bar, borders, and control bu ons 3. Directory:
(minimize, maximize, close). o Descrip on: Provides sta c methods for directory opera ons (create, delete, move).
2. Bu on: o Example: Directory.GetFiles(path)
o Descrip on: A clickable element that performs an ac on when clicked. 4. DirectoryInfo:
o Example: "OK", "Cancel" o Descrip on: Provides instance methods for directory opera ons and proper es.
3. TextBox: o Example: directoryInfo.GetFiles()
o Descrip on: A field where users can enter and edit text. 5. StreamReader:
o Example: Input forms o Descrip on: Reads characters from a byte stream in a par cular encoding.
4. Label: o Example: streamReader.ReadLine()
o Descrip on: Displays sta c text or informa on. 6. StreamWriter:
o Example: Descrip ons, instruc ons o Descrip on: Writes characters to a stream in a par cular encoding.
5. CheckBox: o Example: streamWriter.WriteLine("text")
o Descrip on: A box that can be checked or unchecked to represent a binary choice. 7. BinaryReader:
o Example: "Accept Terms and Condi ons" o Descrip on: Reads primi ve data types as binary values.
6. RadioBu on: o Example: binaryReader.ReadInt32()
o Descrip on: Allows users to select one op on from a group of choices. 8. BinaryWriter:
o Example: Selec ng gender o Descrip on: Writes primi ve data types in binary format.
7. ComboBox: o Example: binaryWriter.Write(123)
o Descrip on: A drop-down list that allows users to select one op on from a list. 9. Path:
o Example: Selec ng a country from a list o Descrip on: Performs opera ons on String instances that contain file or directory path informa on.
8. ListBox: o Example: Path.Combine(path1, path2)
o Descrip on: Displays a list of items from which the user can select one or more. A dialog box in VB.NET is a small window that prompts the user to perform an ac on or provides informa on. It
o Example: File selec on dialog usually requires the user to interact with it before returning to the main applica on.
9. Menu: Types of Dialog Boxes in VB.NET
o Descrip on: A set of commands or op ons presented in a drop-down list. 1. MessageBox:
o Example: File, Edit, View menus o Purpose: Displays a message to the user.
10. ToolBar: o Example: MessageBox.Show("Hello, world!")
o Descrip on: A set of bu ons or icons for quick access to commonly used func ons. 2. InputBox:
o Example: Save, Open, Print icons o Purpose: Prompts the user to enter text.
11. StatusBar: o Example: Dim userInput As String = InputBox("Enter your name:")
o Descrip on: Displays status informa on about the applica on or current opera on. 3. OpenFileDialog:
o Example: "Ready", "Loading" o Purpose: Allows the user to select a file to open.
12. ScrollBar: o Example:
o Descrip on: Allows the user to scroll content ver cally or horizontally. vb
o Example: Scrolling through a document Copy code
13. Panel: Dim openFileDialog As New OpenFileDialog()
o Descrip on: A container that can hold other UI elements, allowing for complex layouts. If openFileDialog.ShowDialog() = DialogResult.OK Then
o Example: Grouping related controls Dim filePath As String = openFileDialog.FileName
14. TabControl: End If
o Descrip on: A control that contains mul ple tabs, each with its own set of controls. 4. SaveFileDialog:
o Example: Tabbed se ngs dialogs o Purpose: Allows the user to select a file loca on to save.
15. ProgressBar: o Example:
o Descrip on: Visual representa on of a task's progress. vb
o Example: File download progress Copy code
FileStream is a class in the System.IO namespace used to read from and write to files. It provides a way to work with Dim saveFileDialog As New SaveFileDialog()
file contents at a low level, offering both synchronous and asynchronous methods for file opera ons. If saveFileDialog.ShowDialog() = DialogResult.OK Then
Commonly Used System.IO Classes Dim filePath As String = saveFileDialog.FileName
1. File: End If
o Descrip on: Provides sta c methods for file opera ons (create, copy, delete, move, open). 5. FolderBrowserDialog:
o Example: File.ReadAllText(path) o Purpose: Allows the user to select a folder.
2. FileInfo: o Example:

vb 2. BackColor: This property sets the background color of the form.


Copy code o Example: form.BackColor = Color.Blue;
Dim folderBrowserDialog As New FolderBrowserDialog() 3. Size: This property sets the size of the form (width and height).
If folderBrowserDialog.ShowDialog() = DialogResult.OK Then o Example: form.Size = new Size(300, 400);
Dim folderPath As String = folderBrowserDialog.SelectedPath 4. StartPosi on: This property sets the posi on where the form will appear on the screen.
End If o Example: form.StartPosi on = FormStartPosi on.CenterScreen;
6. ColorDialog: 5. FormBorderStyle: This property sets the border style of the form (e.g., fixed, sizable, none).
o Purpose: Allows the user to select a color. o Example: form.FormBorderStyle = FormBorderStyle.FixedDialog;
o Example: 6. Visible: This property determines whether the form is visible or not.
vb o Example: form.Visible = true;
Copy code 7. Enabled: This property determines whether the form is enabled or disabled.
Dim colorDialog As New ColorDialog() o Example: form.Enabled = false;
If colorDialog.ShowDialog() = DialogResult.OK Then Fundamental Methods of Windows Forms
Dim selectedColor As Color = colorDialog.Color 1. Show(): This method displays the form on the screen.
End If o Example: form.Show();
7. FontDialog: 2. Hide(): This method hides the form from the screen.
o Purpose: Allows the user to select a font. o Example: form.Hide();
o Example: 3. Close(): This method closes the form.
vb o Example: form.Close();
Copy code 4. Refresh(): This method forces the form to redraw itself.
Dim fontDialog As New FontDialog() o Example: form.Refresh();
If fontDialog.ShowDialog() = DialogResult.OK Then 5. Focus(): This method gives the form the focus, so it becomes the ac ve window.
Dim selectedFont As Font = fontDialog.Font o Example: form.Focus();
End If 6. Ac vate(): This method brings the form to the front and gives it focus.
Types of .NET Assemblies o Example: form.Ac vate();
1. Private Assemblies: Shared Members
o Usage: For a single applica on. Shared members are proper es, methods, or events that belong to the class itself rather than to any specific instance
o Loca on: Applica on's directory. of the class. In other words, you don't need to create an instance of the class to use shared members.
2. Shared Assemblies: In C#, shared members are declared using the sta c keyword.
o Usage: Shared among mul ple applica ons. Examples of Shared Members
o Loca on: Global Assembly Cache (GAC). 1. Shared Property: A property that can be accessed without crea ng an instance of the class.
3. Satellite Assemblies: o Example:
o Usage: Contain localized resources. csharp
o Loca on: Culture-specific subdirectories. Copy code
4. Dynamic Assemblies: public sta c int SharedProperty { get; set; }
o Usage: Created and used at run me. You can access it like this:
o Loca on: In memory or saved to disk during execu on. csharp
Informa on in .NET Assemblies Copy code
1. Metadata: int value = MyClass.SharedProperty;
o Details: Informa on about types (classes, methods, etc.). 2. Shared Method: A method that can be called without crea ng an instance of the class.
2. Intermediate Language (IL) Code: o Example:
o Details: Pla orm-independent compiled code. csharp
3. Manifest: Copy code
o Details: Assembly iden ty (version, culture, etc.). public sta c void SharedMethod()
4. Resource Data: {
o Details: Embedded non-code data (images, strings). // Method code
5. Security Permissions: }
o Details: Required permissions for the assembly. You can call it like this:
6. Type Forwarders: csharp
o Details: Redirect types to another assembly for versioning. Copy code
Fundamental Proper es of Windows Forms MyClass.SharedMethod();
1. Text: This property sets the text displayed in the tle bar of the form. 3. Shared Event: An event that can be subscribed to without crea ng an instance of the class.
o Example: form.Text = "My Applica on"; o Example:
csharp Dim del As MyDelegate = AddressOf Method1
Copy code del += AddressOf Method2 ' Add another method to the delegate
public sta c event EventHandler SharedEvent;
A ribute in .NET ' Invoke the delegate
An a ribute in .NET is a way to add metadata to code elements (like classes, methods, proper es). This metadata can del("Hello World")
provide addi onal informa on about the behavior or usage of the code elements. End Sub
Proper es of A ributes Output:
1. Posi onal Parameters: makefile
o Defini on: Required parameters that must be provided when the a ribute is applied. Copy code
o Example: [Obsolete("This method is obsolete")] Method1: Hello World
2. Named Parameters: Method2: Hello World
o Defini on: Op onal parameters that can be specified by name.
o Example: [Obsolete("This method is obsolete", IsError := True)]
Targets of A ributes
A ributes can be applied to various code elements. The main targets include:
1. Assemblies:
o Example: [assembly: AssemblyVersion("1.0.0.0")]
2. Classes:
o Example: [Serializable]
3. Methods:
o Example: [Obsolete("Use NewMethod instead")]
4. Proper es:
o Example: [XmlElement("CustomerName")]
5. Fields:
o Example: [NonSerialized]
6. Parameters:
o Example: Public Sub MyMethod(<InA ribute()> ByVal input As String)
7. Return Values:
o Example: <return: MarshalAs(UnmanagedType.Bool)> Func on MyFunc on() As Boolean
A ributes add descrip ve informa on to code elements, which can be used at run me or during
Delegates
 Defini on: A delegate is a type that defines a method signature and can hold references to methods with that
signature. It allows methods to be passed as parameters and called indirectly.
Mul cast Delegates
 Defini on: A mul cast delegate is a delegate that can hold references to mul ple methods. When invoked, it calls all
the methods in its invoca on list.
Example
vb
Copy code
' Define a delegate
Public Delegate Sub MyDelegate(ByVal message As String)

' Methods to be called


Public Sub Method1(ByVal message As String)
Console.WriteLine("Method1: " & message)
End Sub

Public Sub Method2(ByVal message As String)


Console.WriteLine("Method2: " & message)
End Sub

' Use the delegate


Sub Main()

You might also like