5 Replies - 3935 Views - Last Post: 01 February 2010 - 06:30 PM Rate Topic: -----

#1 bhabybash  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 18-January 10

getting the output values in textbox and graph it

Post icon  Posted 31 January 2010 - 02:54 AM

anyone can teach me on how to plot a graph using the out put values in textbox

Public Class frmPFC

	Private Sub FillDataGrid()

		Try
			With AxMSChart1
				.DataGrid.SetData(1, 1, txtexPf.Text, 0)
				.DataGrid.SetData(1, 2, txtdesPF.Text, 0)
			End With
		Catch ex As System.Exception
			MessageBox.Show("Error: " & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
		End Try

	End Sub


	Private Sub RadButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadButton1.Click
		FillDataGrid()
		AxMSChart1.Refresh()

		'KVAR's required to improved PF
		If txtexPf.Text = Val(0.5) & (0.59) Then
			txtKVARS.Text = Val(1.039 * txtKW.Text)
		ElseIf txtexPf.Text = Val(0.6) & (0.69) Then
			txtKVARS.Text = Val(0.72 * txtKW.Text)
		ElseIf txtexPf.Text = Val(0.7) & (0.79) Then
			txtKVARS.Text = Val(0.447 * txtKW.Text)
		ElseIf txtexPf.Text = Val(0.8) & (0.89) Then
			txtKVARS.Text = Val(0.183 * txtKW.Text)
		ElseIf txtexPf.Text = Val(0.9) & (0.95) Then
			txtKVARS.Text = Val(0.126 * txtKW.Text)
		End If


		'KVA released
		txtKVARel.Text = Math.Round(Val(txtKW.Text / txtdesPF.Text), 2)

		'Annual Savings
		txtAS.Text = Math.Round(Val(200.59 * txtKVARS.Text * 12), 2)

		'Total Investment Cost
		txtTIC.Text = Math.Round(Val(txtKVARS.Text * 8000), 2)

		'Savings Month
		txtSavings.Text = "12 months"
	End Sub

	Private Sub frmPFC_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		With AxMSChart1
			' 2 series
			.SeriesColumn = 2
			' 1 series = 2 columns
			.ColumnCount() = .SeriesColumn * 3
			.ColumnLabelCount() = .SeriesColumn * 2

			.RowCount() = 1
			.RowLabelCount() = .RowCount

			.DataGrid.SetSize(.RowCount, .ColumnCount, .RowCount, .ColumnCount)

			.chartType = MSChart20Lib.VtChChartType.VtChChartType2dBar
			.ShowLegend = True
			.Plot.UniformAxis = False

			.Title.Text = "Power Factor Correction"
			.Title.VtFont.Name = "Arial"
			.Title.VtFont.Size = 14
			.Title.VtFont.VtColor.Set(20, 150, 20)

			' Background of chartarea
			.Plot.PlotBase.Brush.FillColor.Set(255, 255, 255)
			.Plot.PlotBase.Brush.Style = MSChart20Lib.VtBrushStyle.VtBrushStyleSolid
			.Plot.Backdrop.Fill.Style = MSChart20Lib.VtFillStyle.VtFillStyleBrush
			.Plot.Backdrop.Fill.Brush.FillColor.Set(255, 255, 255)
			.Plot.Backdrop.Frame.Style = MSChart20Lib.VtFrameStyle.VtFrameStyleThickOuter
			.Plot.Backdrop.Frame.FrameColor.Set(10, 75, 10)
		End With

	End Sub


	End Sub
End Class





this is my code but it doesnt seem to accept the output. It works everytime I enter number only.

someone can help me.i attach my form.

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: getting the output values in textbox and graph it

#2 bhabybash  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 18-January 10

Re: getting the output values in textbox and graph it

Posted 31 January 2010 - 09:40 AM

View Postbhabybash, on 31 Jan, 2010 - 01:54 AM, said:

anyone can teach me on how to plot a graph using the out put values in textbox

Public Class frmPFC

	Private Sub FillDataGrid()

		Try
			With AxMSChart1
				.DataGrid.SetData(1, 1, txtexPf.Text, 0)
				.DataGrid.SetData(1, 2, txtdesPF.Text, 0)
			End With
		Catch ex As System.Exception
			MessageBox.Show("Error: " & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
		End Try

	End Sub


	Private Sub RadButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadButton1.Click
		FillDataGrid()
		AxMSChart1.Refresh()

		'KVAR's required to improved PF
		If txtexPf.Text = Val(0.5) & (0.59) Then
			txtKVARS.Text = Val(1.039 * txtKW.Text)
		ElseIf txtexPf.Text = Val(0.6) & (0.69) Then
			txtKVARS.Text = Val(0.72 * txtKW.Text)
		ElseIf txtexPf.Text = Val(0.7) & (0.79) Then
			txtKVARS.Text = Val(0.447 * txtKW.Text)
		ElseIf txtexPf.Text = Val(0.8) & (0.89) Then
			txtKVARS.Text = Val(0.183 * txtKW.Text)
		ElseIf txtexPf.Text = Val(0.9) & (0.95) Then
			txtKVARS.Text = Val(0.126 * txtKW.Text)
		End If


		'KVA released
		txtKVARel.Text = Math.Round(Val(txtKW.Text / txtdesPF.Text), 2)

		'Annual Savings
		txtAS.Text = Math.Round(Val(200.59 * txtKVARS.Text * 12), 2)

		'Total Investment Cost
		txtTIC.Text = Math.Round(Val(txtKVARS.Text * 8000), 2)

		'Savings Month
		txtSavings.Text = "12 months"
	End Sub

	Private Sub frmPFC_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		With AxMSChart1
			' 2 series
			.SeriesColumn = 2
			' 1 series = 2 columns
			.ColumnCount() = .SeriesColumn * 3
			.ColumnLabelCount() = .SeriesColumn * 2

			.RowCount() = 1
			.RowLabelCount() = .RowCount

			.DataGrid.SetSize(.RowCount, .ColumnCount, .RowCount, .ColumnCount)

			.chartType = MSChart20Lib.VtChChartType.VtChChartType2dBar
			.ShowLegend = True
			.Plot.UniformAxis = False

			.Title.Text = "Power Factor Correction"
			.Title.VtFont.Name = "Arial"
			.Title.VtFont.Size = 14
			.Title.VtFont.VtColor.Set(20, 150, 20)

			' Background of chartarea
			.Plot.PlotBase.Brush.FillColor.Set(255, 255, 255)
			.Plot.PlotBase.Brush.Style = MSChart20Lib.VtBrushStyle.VtBrushStyleSolid
			.Plot.Backdrop.Fill.Style = MSChart20Lib.VtFillStyle.VtFillStyleBrush
			.Plot.Backdrop.Fill.Brush.FillColor.Set(255, 255, 255)
			.Plot.Backdrop.Frame.Style = MSChart20Lib.VtFrameStyle.VtFrameStyleThickOuter
			.Plot.Backdrop.Frame.FrameColor.Set(10, 75, 10)
		End With

	End Sub


	End Sub
End Class





this is my code but it doesnt seem to accept the output. It works everytime I enter number only.

someone can help me.i attach my form.



PLEASE HELP ME
Was This Post Helpful? 0
  • +
  • -

#3 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: getting the output values in textbox and graph it

Posted 01 February 2010 - 05:53 AM

Hi,

Just wondering what is the "&" sign in your code supposed to do?

		'KVAR's required to improved PF
		If txtexPf.Text = Val(0.5) & (0.59) Then
			txtKVARS.Text = Val(1.039 * txtKW.Text)
		ElseIf txtexPf.Text = Val(0.6) & (0.69) Then
			txtKVARS.Text = Val(0.72 * txtKW.Text)
		ElseIf txtexPf.Text = Val(0.7) & (0.79) Then
			txtKVARS.Text = Val(0.447 * txtKW.Text)
		ElseIf txtexPf.Text = Val(0.8) & (0.89) Then
			txtKVARS.Text = Val(0.183 * txtKW.Text)
		ElseIf txtexPf.Text = Val(0.9) & (0.95) Then
			txtKVARS.Text = Val(0.126 * txtKW.Text)
		End If



Was This Post Helpful? 0
  • +
  • -

#4 bhabybash  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 18-January 10

Re: getting the output values in textbox and graph it

Posted 01 February 2010 - 06:00 AM

View Postmotcom, on 1 Feb, 2010 - 04:53 AM, said:

Hi,

Just wondering what is the "&" sign in your code supposed to do?

		'KVAR's required to improved PF
		If txtexPf.Text = Val(0.5) & (0.59) Then
			txtKVARS.Text = Val(1.039 * txtKW.Text)
		ElseIf txtexPf.Text = Val(0.6) & (0.69) Then
			txtKVARS.Text = Val(0.72 * txtKW.Text)
		ElseIf txtexPf.Text = Val(0.7) & (0.79) Then
			txtKVARS.Text = Val(0.447 * txtKW.Text)
		ElseIf txtexPf.Text = Val(0.8) & (0.89) Then
			txtKVARS.Text = Val(0.183 * txtKW.Text)
		ElseIf txtexPf.Text = Val(0.9) & (0.95) Then
			txtKVARS.Text = Val(0.126 * txtKW.Text)
		End If




I used & means up to 0.59 values. Is it correct to used "&" ? What should I put?
Was This Post Helpful? 0
  • +
  • -

#5 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: getting the output values in textbox and graph it

Posted 01 February 2010 - 06:14 AM

Hi,

The & sign is not used in that way,
Look at my sample, it will test if the value of txtexPf is between 0.5 and 0.59

 If CDbl(txtexPf.Text) >= 0.5 And CDbl(txtexPf.Text)  <= Val 0.59 Then



the CDbl, Converts the Text to Double.

Now you need to make sure that there is actually a number in the Textbox otherwise "CDbl" will fail

so to see if there is a number in the text, use this

   If IsNumeric(txtexPf.Text) = True then
	  'It is is a valid number
   Else
	  'It is not a valid number
	  'so you might want to warn the user and exit the sub
	  
	  Exit Sub
   End If



Adjust your code and see if it works...

;)
Was This Post Helpful? 0
  • +
  • -

#6 bhabybash  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 18-January 10

Re: getting the output values in textbox and graph it

Posted 01 February 2010 - 06:30 PM

View Postmotcom, on 1 Feb, 2010 - 05:14 AM, said:

Hi,

The & sign is not used in that way,
Look at my sample, it will test if the value of txtexPf is between 0.5 and 0.59

 If CDbl(txtexPf.Text) >= 0.5 And CDbl(txtexPf.Text)  <= Val 0.59 Then



the CDbl, Converts the Text to Double.

Now you need to make sure that there is actually a number in the Textbox otherwise "CDbl" will fail

so to see if there is a number in the text, use this

   If IsNumeric(txtexPf.Text) = True then
	  'It is is a valid number
   Else
	  'It is not a valid number
	  'so you might want to warn the user and exit the sub
	  
	  Exit Sub
   End If



Adjust your code and see if it works...

;)



thank u for that it works. I have another question how you will declare tan-1,cos-1,sin-1 in vb.net
[code]
txtbox3.txt= tan-1 (txtbo1.txt - txtbox2.txt)
txtbox4.txt=cos(txtbox3.text)
[code]
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1