Lid |
|
ik ben bezig met mijn eerste c# programma en wil graag weten wat jullie er van vinden en misschien tips hebben over verbeteringen etc.
hij berekent de tafels van bijv 1 tot en met 10 en je kan ook invoeren hoe ver je door wilt gaan met een tafel bijv de tafels 1 t/m 10 tot 50.
ik zit nu met een probleem hoe controleer je of de ingevoerde text in een textbox een nummer is??
hier is mijn code gedeeltelijk.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Math
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void CalculateBtn_Click(object sender, EventArgs e)
{
int from = Int32.Parse(FromText.Text), to = Int32.Parse(ToText.Text),
RangeStart = Int32.Parse(RangeStartText.Text), RangeStop = Int32.Parse(RangeStopText.Text), result;
if(from.GetTypeCode)
while(from <= to)
{
ResultText.Text = ResultText.Text + "The Table of: " + from + Environment.NewLine;
for (int i = RangeStart; i <= RangeStop; i++)
{
result = from * i;
ResultText.Text = ResultText.Text + from + " * " + i + " = " + result.ToString() + Environment.NewLine;
}
ResultText.Text = ResultText.Text + Environment.NewLine;
from++;
}
}
public void Clear()
{
ResultText.Text = null;
FromText.Text = null;
ToText.Text = null;
RangeStartText.Text = null;
RangeStopText.Text = null;
}
private void Form1_Load(object sender, EventArgs e)
{
Clear();
}
private void ClearBtn_Click(object sender, EventArgs e)
{
Clear();
}
private void InfoBtn_Click(object sender, EventArgs e)
{
}
}
}
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Math { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void CalculateBtn_Click(object sender, EventArgs e) { int from = Int32.Parse(FromText.Text), to = Int32.Parse(ToText.Text), RangeStart = Int32.Parse(RangeStartText.Text), RangeStop = Int32.Parse(RangeStopText.Text), result; if(from.GetTypeCode) while(from <= to) { ResultText.Text = ResultText.Text + "The Table of: " + from + Environment.NewLine; for (int i = RangeStart; i <= RangeStop; i++) { result = from * i; ResultText.Text = ResultText.Text + from + " * " + i + " = " + result.ToString() + Environment.NewLine; } ResultText.Text = ResultText.Text + Environment.NewLine; from++; } } public void Clear() { ResultText.Text = null; FromText.Text = null; ToText.Text = null; RangeStartText.Text = null; RangeStopText.Text = null; } private void Form1_Load(object sender, EventArgs e) { Clear(); } private void ClearBtn_Click(object sender, EventArgs e) { Clear(); } private void InfoBtn_Click(object sender, EventArgs e) { } } }
|