码迷,mamicode.com
首页 > 其他好文 > 详细

一字板计算工具

时间:2015-05-31 06:47:43      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!