[請益] 自學C#一週遇到解不了的地方
看板Soft_Job (軟體人)作者qoo27734266 (postgraduate)時間6年前 (2019/06/18 17:03)推噓8(9推 1噓 28→)留言38則, 16人參與討論串1/1
下面好多熱心大佬一點我就通了 所以已解決 原來是int Sum1 = Numb1 + Convert.ToInt
32(Tbx4Dol2);
的Tbxdol2沒加到text
謝謝
http://sendvid.com/9i15m3gq
———-
大佬們好
小弟商學畢業 想轉職自己買課本來學C#
已經自己練習一週 目前遇到一些程式問題無法解決 麻煩請大佬們幫我看一下
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 電影院售票系統
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Lb1Price.Text = "單價";
Lb2Num.Text = "張數";
Lb3Dol.Text = "金額";
Lb4Ful.Text = "全票";
Lb5Che.Text = "優待票";
Lb6Sum.Text = "合計";
Lb7250.Text = "250";
Lb8200.Text = "200";
Tbx1Num1.Text = "";
Tbx2Num2.Text = "";
Tbx3Dol1.Text = "";
Tbx4Dol2.Text = "";
Tbx5sum1.Text = "";
Tbx3Dol1.ReadOnly = true;
Tbx4Dol2.ReadOnly = true;
Tbx5sum1.ReadOnly = true;
Tbx1Num1.MaxLength = 2;
Tbx2Num2.MaxLength = 2;
Tbx1Num1.TabIndex = 0;
Tbx3Dol1.Text = "0";
Tbx4Dol2.Text = "0";
}
private void Bul5Dol3_Click(object sender, EventArgs e)
{
}
private void Tbx1Num1_TextChanged(object sender, EventArgs e)
{
try
{
int Numb1 = Convert.ToInt32(Tbx1Num1.Text) *
Convert.ToInt32(Lb7250.Text);
Tbx3Dol1.Text = Numb1.ToString();
int Sum1 = Numb1 + Convert.ToInt32(Tbx4Dol2);
Tbx5sum1.Text = Sum1.ToString();
}
catch
{
Tbx3Dol1.Text = "0";
}
}
private void Tbx3Dol1_TextChanged(object sender, EventArgs e)
{
}
private void Tbx2Num2_TextChanged(object sender, EventArgs e)
{
try
{
int Numb2 = Convert.ToInt32(Tbx2Num2.Text) *
Convert.ToInt32(Lb8200.Text);
Tbx4Dol2.Text = Numb2.ToString();
int Total = Numb2 + Convert.ToInt32(Tbx3Dol1.Text);
Tbx5sum1.Text = Total.ToString();
}
catch
{
Tbx2Num2.Text = "0";
}
}
private void Tbx5sum1_TextChanged(object sender, EventArgs e)
{
}
private void Tbx1Num1_Enter(object sender, EventArgs e)
{
}
private void Tbx2Num2_Enter(object sender, EventArgs e)
{
}
}
}
------------------------------------------------------------------
跑出來的程式發現"全票"的"金額"那邊怎麼樣都是0...
我花了三個小時一直改都還是一樣
https://i.imgur.com/xavJLT6.jpg

以下是課本的解答..
https://i.imgur.com/SZ5Gwg2.jpg


我都是自己玩過一次才會去看課本 可是這次課本的我看懂了 大概修的跟課本一樣還是無
法
謝謝 排版不好請見諒
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.133.245.70 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Soft_Job/M.1560848620.A.780.html
※ 編輯: qoo27734266 (223.141.148.134 臺灣), 06/18/2019 17:04:43
※ 編輯: qoo27734266 (223.141.148.134 臺灣), 06/18/2019 17:05:15
※ 編輯: qoo27734266 (223.141.148.134 臺灣), 06/18/2019 17:07:11
→
06/18 17:07,
6年前
, 1F
06/18 17:07, 1F
→
06/18 17:11,
6年前
, 2F
06/18 17:11, 2F
→
06/18 17:11,
6年前
, 3F
06/18 17:11, 3F
推
06/18 17:18,
6年前
, 4F
06/18 17:18, 4F
推
06/18 17:18,
6年前
, 5F
06/18 17:18, 5F
→
06/18 17:22,
6年前
, 6F
06/18 17:22, 6F
→
06/18 17:22,
6年前
, 7F
06/18 17:22, 7F
→
06/18 17:28,
6年前
, 8F
06/18 17:28, 8F
推
06/18 17:28,
6年前
, 9F
06/18 17:28, 9F
推
06/18 17:29,
6年前
, 10F
06/18 17:29, 10F
→
06/18 17:32,
6年前
, 11F
06/18 17:32, 11F
→
06/18 17:37,
6年前
, 12F
06/18 17:37, 12F
推
06/18 17:48,
6年前
, 13F
06/18 17:48, 13F
→
06/18 17:56,
6年前
, 14F
06/18 17:56, 14F
→
06/18 17:57,
6年前
, 15F
06/18 17:57, 15F
推
06/18 17:57,
6年前
, 16F
06/18 17:57, 16F

→
06/18 17:59,
6年前
, 17F
06/18 17:59, 17F
推
06/18 18:00,
6年前
, 18F
06/18 18:00, 18F
→
06/18 18:01,
6年前
, 19F
06/18 18:01, 19F
噓
06/18 18:02,
6年前
, 20F
06/18 18:02, 20F
→
06/18 18:02,
6年前
, 21F
06/18 18:02, 21F
推
06/18 18:07,
6年前
, 22F
06/18 18:07, 22F
→
06/18 18:12,
6年前
, 23F
06/18 18:12, 23F
→
06/18 18:16,
6年前
, 24F
06/18 18:16, 24F
→
06/18 18:16,
6年前
, 25F
06/18 18:16, 25F
→
06/18 18:17,
6年前
, 26F
06/18 18:17, 26F
→
06/18 18:21,
6年前
, 27F
06/18 18:21, 27F
※ 編輯: qoo27734266 (223.141.148.134 臺灣), 06/18/2019 18:33:23
→
06/18 18:35,
6年前
, 28F
06/18 18:35, 28F
→
06/18 18:36,
6年前
, 29F
06/18 18:36, 29F
※ 編輯: qoo27734266 (223.141.148.134 臺灣), 06/18/2019 18:56:06
→
06/18 18:58,
6年前
, 30F
06/18 18:58, 30F
→
06/18 18:59,
6年前
, 31F
06/18 18:59, 31F
→
06/18 18:59,
6年前
, 32F
06/18 18:59, 32F
→
06/18 19:05,
6年前
, 33F
06/18 19:05, 33F
→
06/18 19:12,
6年前
, 34F
06/18 19:12, 34F
→
06/19 10:05,
6年前
, 35F
06/19 10:05, 35F
→
06/19 10:07,
6年前
, 36F
06/19 10:07, 36F
→
06/19 17:28,
6年前
, 37F
06/19 17:28, 37F
推
06/25 00:03,
6年前
, 38F
06/25 00:03, 38F
Soft_Job 近期熱門文章
PTT職涯區 即時熱門文章
17
40