File Dialog VB .NET Program



Description:
           
               We can populate save file dialog and save our file, open the existing file through open file dialog, read that opened file and write the data into rich textbox control.

Save File Dialog

With SaveFileDialog1
                    .DefaultExt = "txt"
                    .FileName = strFileName
                    .Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"
                    .FilterIndex = 1
                    .OverwritePrompt = True
                    .Title = "Demo Save File Dialog"
                End With

                SaveFileDialog1.ShowDialog()
                If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                    Try
                        'Save the file name

                        strFileName = SaveFileDialog1.FileName
                        Dim filePath As String
                        'Open or Create the file
                        filePath = System.IO.Path.Combine( _
                            My.Computer.FileSystem.SpecialDirectories.MyDocuments, _
                            strFileName)
                        'Replace the contents of the file
                        My.Computer.FileSystem.WriteAllText(filePath, RichTextBox1.Text, False)
                    Catch fileException As Exception
                        Throw fileException
                    End Try
                End If


Open File Dialog

With OpenFileDialog1
                    .Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"
                    .FilterIndex = 1
                    .Title = "Demo Open File Dialog"
                End With
                OpenFileDialog1.ShowDialog()
                If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                    Dim allText As String
                    Try
                        'Save the file name
                        strFileName = OpenFileDialog1.FileName
                        'Read the contents of the file
                        allText = My.Computer.FileSystem.ReadAllText(strFileName)
                        'Display the file contents in the TextBox
                        RichTextBox1.Text = allText
                    Catch fileException As Exception
                        Throw fileException
                    End Try
                End If



Contact:
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com

Share:

Error Provider Validation VB .NET Program



Description:         
 
Validate the textbox control whether it has data or not
 Imports System
Imports System.Windows.Forms
Imports System.Drawing

Public Class validation_keyevent
    Private Sub TextBox2_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox2.Validating
        If TextBox2.Text = "" Then
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 15)
            Me.Text = "Error Provider Validation"
            ErrorProvider1.SetError(sender, "You must Provide the First Name")
        Else
            ErrorProvider1.SetError(sender, "")
        End If

    End Sub
    Private Sub TextBox3_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox3.Validating
        If TextBox3.Text = "" Then
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 15)
            Me.Text = "Error Provider Validation"
            ErrorProvider2.SetError(sender, "You must Provide the Last Name")
        Else
            ErrorProvider2.SetError(sender, "")
        End If
    End Sub

    Private Sub TextBox4_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox4.Validating
        If TextBox4.Text = "" Then
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 15)
            Me.Text = "Error Provider Validation"
            ErrorProvider3.SetError(sender, "You must Provide Address")
        Else
            ErrorProvider3.SetError(sender, "")
        End If
    End Sub

  

    Private Sub TextBox6_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox6.Validating

        Select Case TextBox6.Text.Length
            Case 0
                ErrorProvider5.SetError(sender, _TextBox6.Name & " " & "must provide six digits pincode")
            Case 1
                ErrorProvider5.SetError(sender, _TextBox6.Name & " " & "must contain exactly six digits")
            Case 2
                ErrorProvider5.SetError(sender, _TextBox6.Name & " " & "must contain exactly six digits")
            Case 3
                ErrorProvider5.SetError(sender, _TextBox6.Name & " " & "must contain exactly six digits")
            Case 4
                ErrorProvider5.SetError(sender, _TextBox6.Name & " " & "must contain exactly six digits")
            Case 5
                ErrorProvider5.SetError(sender, _TextBox6.Name & " " & "must contain exactly six digits")
            Case Else
                ErrorProvider5.SetError(sender, "")
        End Select
      
    End Sub

    Private Sub TextBox5_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TextBox5.Validating
        If TextBox5.Text = "" Then
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 15)
            Me.Text = "Error Provider Validation"
            ErrorProvider4.SetError(sender, "You must Provide City")
        Else
            ErrorProvider4.SetError(sender, "")
        End If

OUTPUT

Contact:
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704

Email: roshanphelonde@rediffmail.com
Share:

DataGrid With Edit Button VB .NET Program



Description:
           
          The button is added in the data grid column. We will see how display and save data from a database. It will also show how we can edit, delete the data in database through data grid.

Imports System.Windows.Forms
Imports System.Data
Imports System.Data.SqlClient
Public Class griddb
    Dim con As New SqlConnection
    As New SqlCommand
    Dim da As New SqlDataAdapter
    Dim ds As New DataSet
Private Sub griddb_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       
        Me.Orderdetails2TableAdapter.Fill(Me.ShoppingtrollyDataSet.orderdetails2)
       
        con = New SqlConnection("DataSource=COMPUTER10;Initial Catalog=sample;Integrated Security=True")
        con.Open()
        cmd = New SqlCommand("select * from books", con)
        da = New SqlDataAdapter(cmd)
        da.Fill(ds)
        DataGridView1.DataSource = ds
        'DataGridView1.DataBindings()
        con.Close()
    End Sub
protected void Item_Click(Object sender, DataGridCommandEventArgs e)
         Dim pid,cid As New SqlConnection
        TableCell id = e.Item.Cells(1)
       pid = id.Text;
        TableCell idd = e.Item.Cells(0)
        cid = idd.Text;
cmd = New SqlCommand ("deleterecords1", con);
        cmddel.CommandType = CommandType.StoredProcedure;
        cmddel.Parameters.Add(new SqlParameter("@id", SqlDbType.VarChar, 20))
        cmddel.Parameters("@id").Value = pid;
        cmddel.Parameters.Add(new SqlParameter("@idd", SqlDbType.VarChar, 20))
        cmddel.Parameters("@idd").Value = cid;
        con.Open();
        cmddel.ExecuteNonQuery();
        con.Close();
  End Class


OUTPUT


Contact:
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704

Email: roshanphelonde@rediffmail.com
Share:

DataGrid With Combo VB .NET Program



Description:
           
             The Combo box is added in the data grid column. We will see how display and save data from a database. It will also show how we can add Combo Box, Text and other columns types to the Data Grid.


Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.Text
Imports System.Xml
Public Class gridcombo
   
    Private cmbfunctionarea As System.Windows.Forms.ComboBox
    Private dtblfunctionalarea As DataTable
    Private dgdfunctionarea As DataGrid
    PopulateGrid()

    Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick

    End Sub
End Class
frmInitialShortListing()
InitializeComponent()
PopulateGrid()
Private Sub PopulateGrid()
    Dim dtcol As DataColumn = Nothing
    Dim arrstrfunctionalarea As String() = Nothing
    Dim cmbfunctionarea As System.Windows.Forms.ComboBox
    Dim dtblfunctionalarea As DataTable
    cmbfunctionarea = New ComboBox
    cmbfunctionarea.Cursor = System.Windows.Forms.Cursors.Arrow
    cmbfunctionarea.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
    cmbfunctionarea.Dock = DockStyle.Fill
    cmbfunctionarea.SelectionChangeCommitted += New EventHandlercmbfunctionarea_SelectedIndexChanged
    arrstrfunctionalarea = New String(3) {}
    arrstrfunctionalarea(0) = "Functional Area"
    arrstrfunctionalarea(1) = "Min"
    arrstrfunctionalarea(2) = "Max"
    dtblfunctionalarea = New DataTable("Functionlarea")
    Dim i As Integer
    For i = 0 To 2
        Dim str As String = arrstrfunctionalarea(i)
        dtcol = New DataColumn(str)
        dtcol.DataType = System.Type.GetType("System.String")
        dtcol.DefaultValue = ""
        dtblfunctionalarea.Columns.Add(dtcol)
    Next i
    dgdfunctionarea.DataSource = dtblfunctionalarea
    If Not dgdfunctionarea.TableStyles.Contains("Functionarea") Then
        Dim dgdtblStyle As New DataGridTableStyle
        dgdtblStyle.MappingName = dtblfunctionalarea.TableName
        dgdfunctionarea.TableStyles.Add(dgdtblStyle)
        dgdtblStyle.RowHeaderVisible = False
        dgdtblStyle.HeaderBackColor = Color.LightSteelBlue
        dgdtblStyle.AllowSorting = False
        dgdtblStyle.HeaderBackColor=Color.FromArgb(8,36,107)dgtblStyle.RowHeaderVisible=False
        dgdtblStyle.HeaderForeColor = Color.White
        dgdtblStyle.HeaderFont = New System.Drawing.Font("Microsoft Sans")
        ",9F,System.Drawing.FontStyle.Bold,System.Drawing.GraphicsUnit.Point,"(CType(0,System.Byte))
        dgdtblStyle.GridLineColor = Color.DarkGray
        dgdtblStyle.PreferredRowHeight = 22
        dgdfunctionarea.BackgroundColor = Color.White
        Dim colStyle As GridColumnStylesCollection
        colStyle = dgdfunctionarea.TableStyles(0).GriColumnStyles
        colStyle(0).Width = 100
        colStyle(1).Width = 50
        colStyle(2).Width = 50
        colStyle(3).Width = 80
    End If
    Dim dgtb As DataGridTextBoxColumn = CType(dgdfunctionarea.TableStyles(0).GridColumnStyles(0), DataGridTextBoxColumn)
End Sub

OUTPUT


Contact:
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704

Email: roshanphelonde@rediffmail.com
Share:

Color and Font Dialog VB .NET Program

Description:         

We can change the back color and fore color of rich textbox by selected color from color dialog, Change the Text font size, type by the font dialog.

Color Dialog

>private Sub showcolor()
For i = 0 To 1
                    ColorDialog1.ShowDialog()
                    If i = 0 Then
                        If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                            RichTextBox1.BackColor = ColorDialog1.Color
                        End If
                    End If
                    If i = 1 Then
                        If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                            RichTextBox1.ForeColor = ColorDialog1.Color
                        End If
                    End If
                Next
End Sub

OUTPUT


Contact:
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com
Share:

Simple Animation Program Using C Graphics


#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

#define ARROW_SIZE 10

void draw_arrow(int x, int y);

int main(void)
{
   /* request autodetection */
   int gdriver = DETECT, gmode, errorcode;
   void *arrow;
   int x, y, maxx;
   unsigned int size;

   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "..//bgi");

   /* read result of initialization */
   errorcode = graphresult();
   if (errorcode != grOk)  /* an error occurred */
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1); /* terminate with an error code */
   }

   maxx = getmaxx();
   x = 0;
   y = getmaxy() / 2;

   /* draw the image to be grabbed */
   draw_arrow(x, y);

   /* calculate the size of the image */
   size = imagesize(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE);

   /* allocate memory to hold the image */
   arrow = malloc(size);

   /* grab the image */
   getimage(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE, arrow);

   /* repeat until a key is pressed */
   while (!kbhit())
   {
      /* erase old image */
      putimage(x, y-ARROW_SIZE, arrow, XOR_PUT);

      x += ARROW_SIZE;
      if (x >= maxx)
          x = 0;

      /* plot new image */
      putimage(x, y-ARROW_SIZE, arrow, XOR_PUT);
   }

   /* clean up */
   free(arrow);
   closegraph();
   return 0;
}

void draw_arrow(int x, int y)
{
   /* draw an arrow on the screen */
   moveto(x, y);
   linerel(4*ARROW_SIZE, 0);
   linerel(-2*ARROW_SIZE, -1*ARROW_SIZE);
   linerel(0, 2*ARROW_SIZE);
   linerel(2*ARROW_SIZE, -1*ARROW_SIZE);
}


Contact:

Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com
Share:

C Language Program for Mid Point Circle Algorithm Implementation


#include<conio.h>
#include<stdio.h>
#include<graphics.h>
#include<math.h>
#include<dos.h>
int midx,midy,i,gdriver = DETECT, gmode,j,x,y,radius,p,xc,yc,x1,y1;
main()
{
initgraph(&gdriver, &gmode, "..//bgi");
setfillstyle(7,8);
bar(0,35,getmaxx(),getmaxy());
settextstyle( 2,0,7);
border();
setcolor(15);
gotoxy(60,14);
outtextxy(80,200,"ENTER THE VALUES OF X-CENTER ");
scanf("%d",&xc);
gotoxy(60,17);
outtextxy(80,250,"ENTER THE VALUES OF Y-CENTER ");
scanf("%d",&xc,&yc);
gotoxy(60,20);
outtextxy(80,300,"ENTER THE RADIUS OF THE CIRCLE ");
scanf("%d",&radius);
setcolor(BLUE);
for(i=0;i<70;i++)
{
setcolor(4);
settextstyle(1,0,3);
outtextxy(50+3*i,10,"MIDPOINT  CIRCLE ALGORITHM");
setcolor((rand()%10)+1);
circle(20+3*i,19,12);
circle(410+3*i,19,12);
delay(7);
setcolor(0);
settextstyle(1,0,3);
outtextxy(50+3*i,10,"MIDPOINT  CIRCLE ALGORITHM");
circle(20+3*i,19,12);
circle(410+3*i,19,12);
settextstyle(1,0,1);
setfillstyle(7,8);
bar(300,450,610,477);
setcolor(rand()%100);
outtextxy(250,410," ");
delay(1);
}
 setfillstyle(7,1);
  bar(0,0,getmaxx(),getmaxy());
  border();
  setcolor(WHITE);
  line(getmaxx()/2,0,getmaxx()/2,getmaxy());
  line(0,getmaxy()/2,getmaxx(),getmaxy()/2);
midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(4);
x=0;
y=radius;
plotpoints();
p=1-radius;
while(x<y)
{
if(p<0)
{
x=x+1;
p=p+(2*x)+1;
}
else
{
x=x+1;
y=y-1;
p=p+2*(x-y)+1;
plotpoints();
}
}
getch();
closegraph();
return 0;
}
plotpoints()
{
putpixel(xc+x+midx,midy-yc+y,15);
putpixel(xc-x+midx,midy-yc+y,15);
putpixel(xc+x+midx,midy-yc-y,15);
putpixel(midx+xc-x,midy-yc-y,15);
putpixel(midx+xc+y,midy-yc+x,15);
putpixel(midx+xc-y,midy-yc+x,15);
putpixel(midx+xc+y,midy-yc-x,15);
putpixel(midx+xc-y,midy-yc-x,15);
}
border()
{
setcolor(5);
rectangle(0,0,getmaxx(),getmaxy());
rectangle(1,1,getmaxx()-1,getmaxy()-1);
rectangle(2,2,getmaxx()-2,getmaxx()-2);
}



Contact:
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com
Share:

Total Pageviews

CONTACT US

Prof. Roshan P. Helonde
Mobile: +917276355704
WhatsApp: +917276355704
Email: roshanphelonde@rediffmail.com

Enter Project Title

Popular Projects

All Archive

Contact Form

Name

Email *

Message *