下記のコードで、ffBtn_Clickを実行すると、
fresultval = fnicepcnt / ftotalcnt * 100;
でfresultvalの値が0になってしまいます。
やりたいことは、fresultvalに小数付きの値を算出することです
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 WindowsFormsApp2
{
public partial class NicePitching : Form
{
public static int ftotalcnt = 0; public static int fnicepcnt = 0; public static int etotalcnt = 0; public static int enicepcnt = 0; public static decimal fresultval = 0; public static decimal eresultval = 0; public NicePitching() { InitializeComponent(); } private void ftBtn_Click(object sender, EventArgs e) { fnicepcnt += 1; ftotalcnt += 1; fresultval = fnicepcnt / ftotalcnt * 100; this.fResult.Text = fnicepcnt + "/" + ftotalcnt + " " + fresultval.ToString() + "%" ; } private void ffBtn_Click(object sender, EventArgs e) { ftotalcnt += 1; fresultval = fnicepcnt / ftotalcnt * 100; this.fResult.Text = fnicepcnt + "/" + ftotalcnt + " " + fresultval.ToString() + "%"; } }
}