Witam,
Jestem w trakcie robienia zadania w języku C#.
Mam problem z wykończeniem.. Zależy mi na przeniesieniu wartości ze zmiennej typu string z form1 do form2. (To udało mi się jakoś zrobić) Następnie potrzebuję aby tekst który juz jest w form2 sprawdzić w ten sposób
if(passingText == "wesoły")
label1.text = "wesoły"
i tak dalej..
Tutaj form1
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 Ankieta
{
public partial class Start : Form
{
// Deklaruje zmienne klasy Nastrój
Nastroj wesoly, smutny, wkurzony;
public static string passingText;
int licznik;
string Twojhumor = "Wesoły";
public Start()
{
InitializeComponent();
}
// PODSUMUJ ANKIETE
private void podsumujAnkiete_button_Click(object sender, EventArgs e)
{
int naj = wesoly.punktyNastroju;
if (naj < smutny.punktyNastroju)
{
naj = smutny.punktyNastroju;
Twojhumor = "Smutny";
}
else
{
Twojhumor = " Wesoły ";
}
if (naj < wkurzony.punktyNastroju)
{
naj = wkurzony.punktyNastroju;
Twojhumor = "Wkurzony";
}
passingText = Twojhumor;
MessageBox.Show(Twojhumor);
PodsumujAnkiete podsumujAnkiete = new PodsumujAnkiete();
podsumujAnkiete.ShowDialog();
}
}
}
a tutaj form2
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 Ankieta
{
public partial class PodsumujAnkiete : Form
{
public PodsumujAnkiete()
{
InitializeComponent();
}
string humor = Start.passingText;
private void PodsumujAnkiete_Load(object sender, EventArgs e)
{
if (Start.passingText == "Wesoły")
{
twojNastroj_label.Text = Start.passingText;
}
else if (Start.passingText == "Smutny")
{
twojNastroj_label.Text = "Smutny";
}
else if (Start.passingText == "Wkurzony")
{
twojNastroj_label.Text = "Wkurzony";
}
// twojNastroj_label.Text = Start.passingText;
}
}
}