# Fractions Calculator

Page 1 of 1

## 5 Replies - 7481 Views - Last Post: 04 November 2008 - 04:33 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=70102&amp;s=720d28d74991683bb16481455f5752bc&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Malazar

Reputation: 2
• Posts: 27
• Joined: 02-November 08

# Fractions Calculator

Posted 02 November 2008 - 11:03 AM

Ok so I am a beginner and all but I did manage to make a simple calculator on my own but I need some help with a calculator a little more advanced. I want to know how to make a calculator with the ability to divide multiply subtract and add fractions also how to turn a fraction into a mixed number and vice versa. I also want it to turn decimals into fractions and vice versa. I have the basic code for the calc. but I can't figure out the symbol used to signify a fraction help please! Also if you could help with the divide by zero that would be great as I cannot figure out how to work that.
```Public Class Form1
'Integers
Dim FirstNumber As Single
Dim SecondNumber As Single
Dim ArithmeticProcess As String

'Decimal
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
TextBox1.Text = TextBox1.Text & "."
End Sub
'Inserts a one
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = TextBox1.Text & "1"

End Sub
' 2
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = TextBox1.Text & "2"
End Sub
' 3
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox1.Text = TextBox1.Text & "3"
End Sub
'9
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
TextBox1.Text = -TextBox1.Text & "9"
End Sub
'5
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
TextBox1.Text = TextBox1.Text & "5"
End Sub
'6
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
TextBox1.Text = TextBox1.Text & "6"
End Sub
'7
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
TextBox1.Text = TextBox1.Text & "7"
End Sub
'8
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
TextBox1.Text = TextBox1.Text & "8"
End Sub
'4
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
TextBox1.Text = TextBox1.Text & "4"
End Sub
'0
Private Sub cmd0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd0.Click
TextBox1.Text = TextBox1.Text & "0"
End Sub
'clear
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
TextBox1.Text = ""
End Sub
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
FirstNumber = Val(TextBox1.Text)
TextBox1.Text = "0"
ArithmeticProcess = "+"
End Sub
'subtract
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
FirstNumber = Val(TextBox1.Text)
TextBox1.Text = "0"
ArithmeticProcess = "-"
End Sub
'multiply
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
FirstNumber = Val(TextBox1.Text)
TextBox1.Text = "0"
ArithmeticProcess = "X"
End Sub
'divide
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
FirstNumber = Val(TextBox1.Text)
TextBox1.Text = "0"
ArithmeticProcess = "/"
End Sub
'Equels
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
SecondNumber = TextBox1.Text
If ArithmeticProcess = "+" Then
End If
If ArithmeticProcess = "-" Then
End If
If ArithmeticProcess = "/" Then
If SecondNumber = "0" Then
MsgBox("You Cannot Divide By Zero! Besides It Equals Zero Anyway!", 0, "WARNING!")
Exit Sub
End If
End If
If ArithmeticProcess = "x" Then
End If
End Sub
End Class
```

This post has been edited by Malazar: 02 November 2008 - 11:07 AM

Is This A Good Question/Topic? 0

## Replies To: Fractions Calculator

### #2 sam_benne

Reputation: 16
• Posts: 732
• Joined: 16-January 08

## Re: Fractions Calculator

Posted 02 November 2008 - 04:13 PM

Well first i'd sugest giving the buttons proper names so it is easier to understand. For the actual calculator there are many ways it can be done one simpleish way is to do a lot of math. Basically a fraction is two numbers deviding them selves. 1/2 = 1 divided 2. So you can devide the top box by the bottom box, do the same for the other side then do the calculation in between.
Then if you have a full number on the left you times that by the bottom number then add that to the above number simple really.
soon the code will be open source so that will be able to help you.

### #3 PsychoCoder

Reputation: 1654
• Posts: 19,853
• Joined: 26-July 07

## Re: Fractions Calculator

Posted 02 November 2008 - 05:23 PM

Moved to VB.NET

### #4 Malazar

Reputation: 2
• Posts: 27
• Joined: 02-November 08

## Re: Fractions Calculator

Posted 04 November 2008 - 03:20 PM

Okay I have two questions
1) Why was this moved to VB.Net this is Visual Basic 2008? Or is it because no one has updated the forums to include Visual Basic 2008?
and
2) Sam_benne why can't I go to your webbsite or thank you did you delete your account or something?

This post has been edited by Malazar: 04 November 2008 - 03:20 PM

### #5 PsychoCoder

Reputation: 1654
• Posts: 19,853
• Joined: 26-July 07

## Re: Fractions Calculator

Posted 04 November 2008 - 03:24 PM

VB 2008 is VB.NET, it's built on the .Net Framework so that's why I moved it The Visual Basic forum is for older versions of VB, like VB6 and older

### #6 Malazar

Reputation: 2
• Posts: 27
• Joined: 02-November 08

## Re: Fractions Calculator

Posted 04 November 2008 - 04:33 PM

Oh Ok thank you for clearing that up PsychoCoder