Wednesday 11 May 2016

Stopwatch in VB6

Stopwatch in VB6


This is a stopwatch application in VB6 that uses the Timer control. The user has the option to start, stop and reset the stopwatch.

First create the above design of your program in the form designer and then copy the below code into the code window of the vb.




Code:

Dim smallsec As Integer, sec As Integer, min As Integer 
Dim hour As Integer
________________________________________________
Private Sub cmdReset_Click()
    cmdStart.Caption = "Start"

    Timer1.Enabled = False
    Timer2.Enabled = False
    Timer3.Enabled = False

    Text1.Text = Format(0, "00")
    Text2.Text = Format(0, "00")
    Text3.Text = Format(0, "00")
End Sub
________________________________________________
Private Sub cmdStart_Click()

    If cmdStart.Caption = "Start" Then
        cmdStart.Caption = "Stop"
    Else
        cmdStart.Caption = "Start"
    End If


    If cmdStart.Caption = "Stop" Then
        Timer3.Enabled = True
        Timer2.Enabled = True
        Timer1.Enabled = True
    Else
        Timer3.Enabled = False
        Timer2.Enabled = False
        Timer1.Enabled = False
    End If
End Sub
________________________________________________
Private Sub Timer1_Timer()
    If txtMinute.Text < 59 Then
        txtMinute.Text = Format(txtMinute.Text + 1, "00")
    Else
        txtMinute.Text = Format(0, "00")
    End If
End Sub
________________________________________________
Private Sub Timer2_Timer()
    If txtSecond.Text < 59 Then
        txtSecond.Text = Format(txtSecond.Text + 1, "00")
    Else
        txtSecond.Text = Format(0, "00")
    End If
End Sub
________________________________________________
Private Sub Timer3_Timer()
    If txtMiniSecond.Text < 99 Then
        txtMiniSecond.Text = Format(txtMiniSecond.Text + 1, "00")
    Else
        txtMiniSecond.Text = Format(0, "00")
    End If
End Sub

Copy-Paste Sample in Visual Basic 6

Copy-Paste Sample in Visual Basic 6




This is a copy paste sample in Visual Basic 6. It shows you how to use the clipboard object in VB6 to perform copy paste operations in your application. This is a very easy sample targeted to the beginners. It shows you the use of the clipboard object very simply and in a straightforward way avoiding the complexities related to this object. Of course, you can make a complex program using the Clipboard object to achieve something of a very high level. 
The code for the above program is very simple and two command buttons are used in the program:
1: cmdCopy2: cmdPaste

First create the above design of your program in the form designer and then copy the below code into the code window of the vb.

Code:

Private Sub cmdCopy_Click()

    Clipboard.SetText (txtCopy.Text)

End Sub

Private Sub cmdPaste_Click()

    txtPaste.Text = Clipboard.GetText

End Sub


Thank You.
For any other program please comment in the comment box and get any program related to C,C++,VB6 or VB 2010.

Creating Traffic Light Using VB

                         Creating Traffic Light Using VB                            


First create the above design of your traffic light in the form designer and then copy the below code into the code window of the vb.

Note: 

Fill the circles or ovals made for the traffic lights with the red,yellow and green color before you start coding.
Also, add the three timers from the toolbox.
AS, this is VB 2010 the timers are not visible but if you are using VB 6 the timers will be visible at the side of each light.
So add 3 timers at the side of each coloured circle or oval.

Code:


 Private Sub OvalShape2_Click(sender As System.Object, e As System.EventArgs) Handles OvalShape2.Click

    End Sub

    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        OvalShape1.Visible = True
        OvalShape2.Visible = False
        OvalShape3.Visible = False
        Timer1.Enabled = False
        Timer2.Enabled = True
    End Sub

    Private Sub Timer2_Tick(sender As System.Object, e As System.EventArgs) Handles Timer2.Tick
        OvalShape1.Visible = False
        OvalShape2.Visible = True
        OvalShape3.Visible = False
        Timer2.Enabled = False
        Timer3.Enabled = True
    End Sub

    Private Sub Timer3_Tick(sender As System.Object, e As System.EventArgs) Handles Timer3.Tick
        OvalShape1.Visible = False
        OvalShape2.Visible = False
        OvalShape3.Visible = True
        Timer3.Enabled = False
        Timer1.Enabled = True
    End Sub
    Friend WithEvents RectangleShape1 As Microsoft.VisualBasic.PowerPacks.RectangleShape
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents Button6 As System.Windows.Forms.Button

    Private Sub Button6_Click(sender As System.Object, e As System.EventArgs) Handles Button6.Click
        Timer1.Enabled = True
        OvalShape1.Visible = True
        OvalShape2.Visible = False
        OvalShape3.Visible = False
    End Sub
    Friend WithEvents Button7 As System.Windows.Forms.Button

    Private Sub Button7_Click(sender As System.Object, e As System.EventArgs) Handles Button7.Click
        Timer1.Enabled = False
        Timer2.Enabled = False
        Timer3.Enabled = False
        OvalShape1.Visible = False
        OvalShape2.Visible = False
        OvalShape3.Visible = False
    End Sub
End Class

Code for VB 6 Users :


Private Sub Form_Load()


Timer1.Enabled = True


Shape1.Visible = True


Shape2.Visible = False


Shape3.Visible = False


 


End Sub


Private Sub Timer1_Timer()


If Shape1.Visible Then


 


Shape2.Visible = True


Shape1.Visible = False


Shape3.Visible = False


 


ElseIf Shape2.Visible Then


 


Shape3.Visible = True


Shape2.Visible = False


Shape1.Visible = False


 


Else


 


Shape1.Visible = True


Shape2.Visible = False


Shape3.Visible = False


 


End If


 


End Sub

Calculator using VB

Calculator using VB


First create the above design of your calculator in the form designer and then copy the below code into the code window of the vb.

Code:


    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        TextBox3.Text = TextBox1.Text + TextBox2.Text
    End Sub
    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        TextBox3.Text = TextBox1.Text - TextBox2.Text
    End Sub
    Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
        TextBox3.Text = TextBox1.Text / TextBox2.Text
    End Sub
    Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
        TextBox3.Text = TextBox1.Text * TextBox2.Text
    End Sub

Microsoft Virtual Studio

Microsoft Virtual Studio


Its is a rich, integrated development environment for creating stunning applications for Windows, Android, and iOS, as well as modern web applications and cloud services.

Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft. It is used to develop computer programs for Microsoft Windows, as well as web sitesweb applications and web services. Visual Studio uses Microsoft software development platforms such as Windows APIWindows FormsWindows Presentation FoundationWindows Store and Microsoft Silverlight. It can produce both native code and managed code.

The term virtual studio can refer to any number of technological tools which seek to simulate a physical television and/or movie studio.

Visual Studio does not support any programming language, solution or tool intrinsically; instead, it allows the plugging of functionality coded as a VSPackage. When installed, the functionality is available as a Service. The IDE provides three services: SVsSolution, which provides the ability to enumerate projects and solutions; SVsUIShell, which provides windowing and UI functionality (including tabs, toolbars and tool windows); and SVsShell, which deals with registration of VSPackages. In addition, the IDE is also responsible for coordinating and enabling communication between services.[9] All editors, designers, project types and other tools are implemented as VSPackages. Visual Studio uses COM to access the VSPackages. The Visual Studio SDK also includes the Managed Package Framework (MPF), which is a set of managed wrappers around the COM-interfaces that allow the Packages to be written in any CLI compliant language.[10] However, MPF does not provide all the functionality exposed by the Visual Studio COM interfaces.[11] The services can then be consumed for creation of other packages, which add functionality to the Visual Studio IDE.


Wednesday 4 May 2016

Searching element in array using pointers

#include<iostream.h>
#include<conio.h>
void main()
{
int a[5],*p,no,flag=0,i;
clrscr();
p=&a[0];
cout<<"Enter Elements:";
for(i=0;i<5;i++)
{
cin>>*p;
p++;
}
p=&a[0];
cout<<"Enter no to be searched:";
cin>>no;
for(i=0;i<5;i++)
{
if(*p==no)
{
cout<<"No is present";
flag=0;
break;
}
else
{
flag=1;
}
p++;
}
if(flag==1)
{
cout<<"No not present";
}
getch();
}


Copying the array elements using pointers.

#include<iostream.h>
#include<conio.h>
void main()
{
int a[5],*p,i,b[5],*q;
clrscr();
p=&a[0];
q=&b[0];
cout<<"Enter elements:";
for(i=0;i<5;i++)
{
cin>>*p;
p++;
}
p=&a[0];
for(i=0;i<5;i++)
{
*q=*p;
p++;
q++;
}
q=&b[0];
cout<<"Copied String:";
for(i=0;i<5;i++)
{
cout<<" "<<*q;
q++;
}
getch();
}

What is a Pointer ?

A pointer is a memory variable that stores the memory address of another variable.