0


Xaml.vb 

 Class MainWindow

    Dim op As Integer
    Dim fn As Long

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
        TextBox1.Text = TextBox1.Text + Button1.Content
    End Sub

    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button10.Click
        TextBox1.Text = TextBox1.Text + Button10.Content
    End Sub

    Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        op = 4
        fn = TextBox1.Text
        TextBox1.Text = ""
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button6.Click
        TextBox1.Text = TextBox1.Text + Button6.Content
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button2.Click
        TextBox1.Text = TextBox1.Text + Button2.Content
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button3.Click
        TextBox1.Text = TextBox1.Text + Button3.Content
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button4.Click
        TextBox1.Text = TextBox1.Text + Button4.Content
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button5.Click
        TextBox1.Text = TextBox1.Text + Button5.Content
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button7.Click
        TextBox1.Text = TextBox1.Text + Button7.Content
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button8.Click
        TextBox1.Text = TextBox1.Text + Button8.Content
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button9.Click
        TextBox1.Text = TextBox1.Text + Button9.Content
    End Sub

    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button13.Click
        op = 1
        fn = TextBox1.Text
            TextBox1.Text = ""
       
    End Sub

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button11.Click
        TextBox1.Text = ""
    End Sub

    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button12.Click
        If op = 1 Then
            TextBox1.Text = fn + TextBox1.Text
        ElseIf op = 2 Then
            TextBox1.Text = fn - TextBox1.Text
        ElseIf op = 3 Then
            TextBox1.Text = fn * TextBox1.Text
        ElseIf op = 4 And TextBox1.Text > 0 Then
            TextBox1.Text = fn / TextBox1.Text
        Else
            TextBox1.Text = "Divide By Zero Is Not Possible"
        End If
    End Sub

    Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button15.Click
        op = 2
        fn = TextBox1.Text
        TextBox1.Text = ""
    End Sub

    Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button14.Click
        op = 3
        fn = TextBox1.Text
        TextBox1.Text = ""
    End Sub

    Private Sub Button16_Click_1(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button16.Click
        op = 4
        fn = TextBox1.Text
        TextBox1.Text = ""
    End Sub
End Class

Mainwindows.xaml

<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Calculator By Ahmedhaseeb" Icon="/WpfApplication1;component/Images/favicon.png" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Height="537" Width="505">
    <Grid DataContext="{Binding}">
        <Image Height="521" HorizontalAlignment="Left" Name="Image1" Stretch="UniformToFill" VerticalAlignment="Top" Width="516" Source="/WpfApplication1;component/Images/1800219_584866314939958_1887549245_n.jpg" StretchDirection="Both" Visibility="Visible" Opacity="50" Margin="0,-23,0,0" />
        <Button Content="1" Height="24" HorizontalAlignment="Left" Margin="10,228,0,0" Name="Button1" VerticalAlignment="Top" Width="80" />
        <TextBox Height="40" HorizontalAlignment="Left" Margin="10,12,0,0" Name="TextBox1" VerticalAlignment="Top" Width="470" />
        <Button Content="2" Height="24" HorizontalAlignment="Left" Margin="102,228,0,0" Name="Button2" VerticalAlignment="Top" Width="80" />
        <Button Content="3" Height="24" HorizontalAlignment="Left" Margin="188,228,0,0" Name="Button3" VerticalAlignment="Top" Width="80" />
        <Button Content="4" Height="24" HorizontalAlignment="Left" Margin="10,190,0,0" Name="Button4" VerticalAlignment="Top" Width="80" />
        <Button Content="5" Height="24" HorizontalAlignment="Left" Margin="102,190,0,0" Name="Button5" VerticalAlignment="Top" Width="80" />
        <Button Content="6" Height="24" HorizontalAlignment="Left" Margin="188,190,0,0" Name="Button6" VerticalAlignment="Top" Width="80" />
        <Button Content="7" Height="24" HorizontalAlignment="Left" Margin="10,153,0,0" Name="Button7" VerticalAlignment="Top" Width="80" />
        <Button Content="8" Height="24" HorizontalAlignment="Left" Margin="102,153,0,0" Name="Button8" VerticalAlignment="Top" Width="80" />
        <Button Content="9" Height="24" HorizontalAlignment="Left" Margin="188,153,0,0" Name="Button9" VerticalAlignment="Top" Width="80" />
        <Button Content="0" Height="24" HorizontalAlignment="Left" Margin="10,258,0,0" Name="Button10" VerticalAlignment="Top" Width="80" />
        <Button Content="Clear" Height="24" HorizontalAlignment="Left" Margin="98,258,0,0" Name="Button11" VerticalAlignment="Top" Width="84" />
        <Button Content="=" Height="24" HorizontalAlignment="Left" Margin="188,258,0,0" Name="Button12" VerticalAlignment="Top" Width="80" />
        <Button Content="+" Height="24" HorizontalAlignment="Left" Margin="287,190,0,0" Name="Button13" VerticalAlignment="Top" Width="84" />
        <Button Content="*" Height="24" HorizontalAlignment="Left" Margin="287,228,0,0" Name="Button14" VerticalAlignment="Top" Width="84" />
        <Button Content="-" Height="24" HorizontalAlignment="Left" Margin="387,190,0,0" Name="Button15" VerticalAlignment="Top" Width="84" />
        <Button Content="/" Height="24" HorizontalAlignment="Left" Margin="387,228,0,0" Name="Button16" VerticalAlignment="Top" Width="84" />
    </Grid>
</Window>

Post a Comment

 
Top