Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

VB.NET cases and radio


  • Please log in to reply

#1
bluntknife

bluntknife

    Member

  • Member
  • PipPip
  • 55 posts
well basicly i have a form with 3 radio buttons on and depending on which radio button is pressed it will show a differant group box. Each group box contains a number of text boxs which will be used to calculate a differant equation when i single button is pressed. i wish to do this equation through case statements which are built into the calculate button.

need any more info just post back :)


** DONE **

Edited by bluntknife, 19 September 2007 - 12:47 PM.

  • 0

Advertisements


#2
stettybet0

stettybet0

    Trusted Tech

  • Technician
  • 2,579 posts
Um, that sounds great and all, but you didn't really say what you needed help with... :)

Also, which version of VB.NET are you using?
  • 0

#3
bluntknife

bluntknife

    Member

  • Topic Starter
  • Member
  • PipPip
  • 55 posts
Thanks for the replie stettybet0, i have figures the problem out now. the is one thing tho.

basicly i have formatted the data output to 2 decimal places ad two of the outputs show correctly but the triangle calculations does add the formatting and just displays all of the number. just wondering if there was any info you could give.

i have include the whole program code (it may not to the best way of doing th program but it meets the eeds of the problem i was given, other then the triangle output not displaying to 2 decimal places.
Public Class frmarea

	'****************************************************************************
	'****************************************************************************
	'**																		**
	'**	 Project name		: Area Calulator							   **
	'**	 Project description : Use to calculate the areas of three shapes   **
	'**	 Author			  : Edward Hunkin								**
	'**	 Date				: 18 September 2007							**
	'**																		**
	'****************************************************************************
	'****************************************************************************

	Dim a, b, c, area As Double
	Dim sentence As String

	Private Sub radrectangle_GotFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radrectangle.CheckedChanged
		grprectangle.Visible = True
		grpcircle.Visible = False
		grptriangle.Visible = False
	End Sub

	Private Sub radcircle_GotFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radcircle.CheckedChanged
		grprectangle.Visible = False
		grpcircle.Visible = True
		grptriangle.Visible = False
	End Sub

	Private Sub radtriangle_GotFocusd(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radtriangle.CheckedChanged
		grprectangle.Visible = False
		grpcircle.Visible = False
		grptriangle.Visible = True
	End Sub

	Private Sub btncalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalculate.Click
		Dim a, b, c, s, d As Double
		a = 0
		b = 0
		c = 0
		d = area = 0
		Try
			If radrectangle.Checked = True Then
				a = txtlength.Text
				b = txtbreadth.Text
				area = (a * b)
				Call output()
				txtlength.Clear()
				txtbreadth.Clear()

			ElseIf radcircle.Checked = True Then
				a = txtradius.Text
				area = 3.142 * (a * a)
				Call output()
				txtradius.Clear()

			ElseIf radtriangle.Checked = True Then
				a = txtside1.Text
				b = txtside2.Text
				c = txtside3.Text
				s = (a + b + c) / 2
				area = Math.Sqrt(s * (s - a) * (s - b) * (s - c))
				Call output()
				txtside1.Clear()
				txtside2.Clear()
				txtside3.Clear()

			End If
		Catch ex As Exception
			MsgBox("Not enough information entered. Please try again")
		End Try
	End Sub
	Sub output()
		area.ToString("0.00")
		sentence = "The area of your shape is " & area & " Square cm"
		lblarea.Text = sentence

	End Sub
End Class


If you can understand all that you are a genus :)
  • 0

#4
stettybet0

stettybet0

    Trusted Tech

  • Technician
  • 2,579 posts
Instead of

area.ToString("0.00")

use

area = FormatNumber(area, 2)

or

area = area.ToString("0.00")

Personally, I like to use FormatNumber because it allows more options if needed, but in this case, either would be fine.

Edited by stettybet0, 23 September 2007 - 06:07 PM.

  • 0

#5
bluntknife

bluntknife

    Member

  • Topic Starter
  • Member
  • PipPip
  • 55 posts
thanks thanks for your replies stettybet0, in the end i use a new variable and went

area = areatotal.tostring("0.00)

  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP