标签:
1.核心代码
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; namespace ZTBCalc { public partial class ZTB : Form { public ZTB() { InitializeComponent(); } public bool IsFloat(string s) { float p=0; float.TryParse(s, out p); return p>0; } public bool IsInt(string s) { int p = 0; int.TryParse(s, out p); return p >= 1 && p<=1000; } /// <summary> /// 涨停板 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnUpStop_Click(object sender, EventArgs e) { Msg.Items.Clear(); if (!IsFloat(txtPrice.Text)) { Msg.ForeColor = Color.Red; Msg.Items.Clear(); Msg.Items.Add("请输入大于0的价格"); return; } if (!IsInt(txtYZBNum.Text)) { Msg.ForeColor = Color.Red; Msg.Items.Clear(); Msg.Items.Add("一字板取值范围(1-1000)"); return; } Msg.ForeColor = Color.Red; Msg.Items.Add("歌曰: "); Msg.Items.Add(" 咱老百姓啊,今儿个真高兴, "); Msg.Items.Add(" 机会难得,美梦成真,财务自由,可喜可贺。 "); float basePrice = Convert.ToSingle(txtPrice.Text); int YZBNum = Convert.ToInt32(txtYZBNum.Text); for (int i = 1; i <= YZBNum; i++) { float currentPrice = basePrice + basePrice * 0.1f; Msg.Items.Add("第 " + i + " 个涨停板: " + currentPrice.ToString("f2")); basePrice = currentPrice; } } /// <summary> /// 跌停板 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnDownStop_Click(object sender, EventArgs e) { Msg.Items.Clear(); Msg.ForeColor = Color.Green; if (!IsFloat(txtPrice.Text)) { Msg.Items.Clear(); Msg.Items.Add("请输入大于0的数字"); return; } if (!IsInt(txtYZBNum.Text)) { Msg.ForeColor = Color.Red; Msg.Items.Clear(); Msg.Items.Add("一字板取值范围(1-1000)"); return; } Msg.Items.Add("诗云: "); Msg.Items.Add(" 春风它轻轻抬起了头, 大地一片绿油油。"); Msg.Items.Add(" 庄家和主力拿起了刀, 韭菜割呀割呀割。"); Msg.ForeColor = Color.Green; float basePrice = Convert.ToSingle(txtPrice.Text); int YZBNum = Convert.ToInt32(txtYZBNum.Text); for (int i = 1; i <= YZBNum; i++) { if (basePrice <= 0.0f) { i = YZBNum; return; } float currentPrice = basePrice - basePrice * 0.1f; Msg.Items.Add("第 " + i + " 个跌停板: " + currentPrice.ToString("f2")); basePrice = currentPrice; } } private void ZTB_Load(object sender, EventArgs e) { } } }
2.运行截图
3,源代码地址 和可运行程序地址
http://pan.baidu.com/s/1ntmTojJ
标签:
原文地址:http://www.cnblogs.com/HCCZX/p/4541438.html