Click here to Skip to main content
15,903,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
So i have made a Prime Numbers Printer in C# console app how do i make it using the Windows form in visual studio
P.S i know i can make it more efficient and i am working on one but how do i bring this into the Visual GUI

Shared album - Burning Blaze - Google Photos[^]

What I have tried:

My code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PM_gui
{
    public partial class TBFromWhere : Form
    {
        public TBFromWhere()
        {
            InitializeComponent();
        }

        private void ButGen_Click(object sender, EventArgs e)
        {
            int NB1, NB2;
            NB1 = Convert.ToInt32(textBox1.Text);
            NB2 = Convert.ToInt32(TBTillWhere.Text);
            while (NB1 < NB2)
            {
                if (NB1 < NB2)
                {
                    bool Prime = true;
                    if (NB1 % 2 == 0)
                    {
                        Prime = false;
                    }
                    for (int i = 3; i * i <= NB1; i += 2)
                    {
                        if (NB1 % i == 0)
                        {
                            Prime = false;
                        }
                    }
                    if (Prime == true)
                    {
                        label3.Text = NB1.ToString("n");
                    }
                    if (Prime == false)
                    {
                        NB1 = NB1 + 1;
                    }
                }
            }
        }

        private void vScrollBar2_Scroll(object sender, ScrollEventArgs e)
        {
            label3.Text = vScrollBar2.Value.ToString();
        }
    }

}
Posted
Updated 24-Jul-18 1:48am
v2

1 solution

That's absolutely not the purpose of a label. What you actually want to use is a ComboBox.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900