You first of all need to put your TryParse in an if statement because what happens it it doesn't parse out to a double? Then you are in trouble.
//exampleif (Double.TryParse(test4.Text, out number))
{
.........
}
Fix that first, and make the rest of the functionality is in that if statement.
Here is an example of a Trackbar functionality. It has a label, three Trackbar, and a pictureBox. When you adjust the TrackBar, it adjusts the RGB color on the pictureBox
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
tbBlue.Value = 0;
tbGreen.Value = 0;
tbRed.Value = 0;
UpdateColor();
}
private void Scoll(object sender, EventArgs e)
{
UpdateColor();
}
private void UpdateColor()
{
Color c = Color.FromArgb(tbRed.Value, tbGreen.Value, tbBlue.Value);
colorBox.BackColor = c;
lblCurrColor.Text = "Current color is: (" + tbRed.Value + ", " + tbGreen.Value + " ," + tbBlue.Value + ")";
}
}
}
John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com