Problem with INT

  • Thread starter Thread starter MesikaX
  • Start date Start date
M

MesikaX

Guest
Hey, <g class="gr_ gr_13 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="13" id="13">im</g> trying to do <g class="gr_ gr_197 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins doubleReplace replaceWithoutSep" data-gr-id="197" id="197">button</g> that everytime you click on him its double the number value (money value).

But, there is a catch, I use random to random an event that Reset the Value to 1.

I got a problem with the code, he is working well sometimes and sometimes <g class="gr_ gr_411 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="411" id="411">dont</g> to the math <g class="gr_ gr_438 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" data-gr-id="438" id="438">good</g>. (I create saved <g class="gr_ gr_484 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="484" id="484">moneybalance</g> that located and count your money balance and <g class="gr_ gr_689 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" data-gr-id="689" id="689">everytime</g> you push the button that <g class="gr_ gr_687 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" data-gr-id="687" id="687">add</g> <g class="gr_ gr_734 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" data-gr-id="734" id="734">your money</g> that you <g class="gr_ gr_722 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="722" id="722">acihve</g> from pressing the button to the <g class="gr_ gr_781 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="781" id="781">currect</g> balance but its sometimes do a wrong math and <g class="gr_ gr_952 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="952" id="952">somethimes</g> its reset the value or do a <g class="gr_ gr_1057 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="1057" id="1057">someting</g> that make the Balance less.

<g class="gr_ gr_1173 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="1173" id="1173">Im</g> <g class="gr_ gr_1177 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="1177" id="1177">begginer</g> <g class="gr_ gr_1184 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del" data-gr-id="1184" id="1184">so <g class="gr_ gr_1218 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" data-gr-id="1218" id="1218">i</g></g> think the code <g class="gr_ gr_1217 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" data-gr-id="1217" id="1217">its</g> not so complicated but <g class="gr_ gr_1312 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" data-gr-id="1312" id="1312">i</g> hope you can help me to find my bug.

Thank you <3

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApp1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
int t1; //value in the button

int balance; //balance from the button

int a; //random_num

int savedbalance; //currect balance, (He gets
+_balance with click on button)

public MainWindow()
{
InitializeComponent();
t1 = 1;
Money.FontSize = 72; //money= labelname
Money.FontWeight = FontWeights.Bold;

}



private void CB_Click_1(object sender, RoutedEventArgs e)
{
Random r = new Random();
int a = r.Next(1, 100);
te.Content = a;

if (a<90)
{
if (t1 < 1000)
{
Money.Content = t1;
t1 = t1 + t1;
}
else
{
Money.FontSize = 50;
Money.Content = t1;
t1 = t1 + t1;
}
} else
{
t1 = 1;
Money.Content = t1;

}


}

private void Button_Click(object sender, RoutedEventArgs e)
{

balance = t1 / 2;
MonBalance.FontSize = 35; //saved balance
label name
MonBalance.Content = savedbalance +
balance;
Money.FontWeight = FontWeights.Bold;
savedbalance = balance;
t1 = 1;





}
}
}

Continue reading...
 
Back
Top