Jak wypisać wartości z funkcji w okienku textbox?

0

Witam,

mam metodę która wykonuje pewną funkcję piramidalna(arg), i ta metoda zwraca pewna wartość.

Chcę zrobić tak żeby te wartości były wypisane w tym oknie gdzie są te wszystkie buttony itd.

Visual Studio 2010

Jednak mam problem jak to zrobić.

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;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            StreamReader sr;
            StreamWriter sr2,sr3;

            string wartosc1;

            int liczba;

            sr = new StreamReader("liczby.txt");
            sr2 = new StreamWriter("parzyste.txt");
            sr3 = new StreamWriter("nieparzyste.txt");

            while (sr.EndOfStream == false)
            {

                wartosc1= sr.ReadLine();

                if (string.IsNullOrEmpty(wartosc1))
                    continue;

                string[] tabs = wartosc1.Split(' ');

                foreach (string tab in tabs)
                {
                    liczba = int.Parse(tab);
                    
                    if (liczba % 2 == 0)
                    {
                        sr2.Write(liczba);
                        sr2.Write(' ');
                    }
                    else
                    {
                        sr3.Write(liczba);
                        sr3.Write(' ');
                    }
                    
                }
            }
            sr.Close();
            sr2.Close();
            sr3.Close();

        }

        private void button2_Click(object sender, EventArgs e)
        {
            double arg=0;
            int x;

            
            x = Console.Read();

            for (int i = x - 1; i > 0; i--)
            {
                if (i % 2 != 0)
                    piramidalna(arg);


            }
        }

        

        public double piramidalna(double arg)
        {
            double a,b;

            a = arg*(arg*arg-1);
            
            return a;
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            TextBox dynamicTextBox = new TextBox();
            
        }

        
    }
}
 
0

Wczytywanie plików możesz zrobić łatwiej i krócej, zerknij do MSDN za ReadAllLines.
Co do wypisywania to możesz walnąć jakąś kontrolkę i zrobić xxx.Text/Caption/Label/blablabla = piramidalna(ble).ToString(); albo rysowac po Canvasie.
Nie podajesz konkretnie jak chcesz to wypisać więc konkretnej odpowiedzi nie dostaniesz.

1 użytkowników online, w tym zalogowanych: 0, gości: 1