C#编写的生辰八字计算程序

作者故意删除了注释,读不懂代码的,就加作者QQ721159175咨询吧,作者很乐意与你分享并解答~

代码如下:

using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //假设一个人的公历出生时间,范围必须要在2012-2015年之间,因为本示例程序只提供了这几年的农历数据
            //修改这几个赋值,运行程序,可以得到生辰八字
            GuaZhu.nQiGuaYear = 2015;//年
            GuaZhu.nQiGuaMonth = 2;//月
            GuaZhu.nQiGuaDay = 6;//日
            GuaZhu.nQiGuaHour = 23;//时
            GuaZhu.nQiGuaMinute = 33;//分
            GuaZhu.GetSiZhu();
        }
    }
    public static class GuaZhu
    {
        public static int nQiGuaYear;
        public static int nQiGuaMonth;
        public static int nQiGuaDay;
        public static int nQiGuaHour;
        public static int nQiGuaMinute;
        public static int JieQiMonth;
        public static string PrevJQYear;
        public static string PrevJQMonth;
        public static string PrevJQDay;
        public static string PrevJQHour;
        public static string PrevJQMinute;
        public static string NextJQYear;
        public static string NextJQMonth;
        public static string NextJQDay;
        public static string NextJQHour;
        public static string NextJQMinute;
        public static string sSiZhu;
        public static string nTianGan;
        public static string yTianGan;
        public static string rTianGan;
        public static string sTianGan;
        public static string nDiZhi;
        public static string yDiZhi;
        public static string rDiZhi;
        public static string sDiZhi;
        public static int nTianGanID;
        public static int yTianGanID;
        public static int rTianGanID;
        public static string PrevJieQi;
        public static string NextJieQi;
        public static string[] TianGan = { "甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸" };
        public static string[] DiZhi = { "子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥" };
        public static string[] JieQi = {
"1/6/2012 06:44","2/4/2012 18:22","3/5/2012 12:21","4/4/2012 17:06","5/5/2012 10:20","6/5/2012 14:26","7/7/2012 00:41",
"8/7/2012 10:31","9/7/2012 13:29","10/8/2012 05:12","11/7/2012 08:26","12/7/2012 01:19","1/5/2013 12:34","2/4/2013 00:13",
"3/5/2013 18:15","4/4/2013 23:02","5/5/2013 16:18","6/5/2013 20:23","7/7/2013 06:35","8/7/2013 16:20","9/7/2013 19:16",
"10/8/2013 10:58","11/7/2013 14:14","12/7/2013 07:09","1/5/2014 18:24","2/4/2014 06:03","3/6/2014 00:02","4/5/2014 04:47",
"5/5/2014 21:59","6/6/2014 02:03","7/7/2014 12:15","8/7/2014 22:03","9/8/2014 01:01","10/8/2014 16:48","11/7/2014 20:07",
"12/7/2014 13:04","1/6/2015 00:20","2/4/2015 11:58","3/6/2015 05:55","4/5/2015 10:39","5/6/2015 03:52","6/6/2015 07:58",
"7/7/2015 18:12","8/6/2015 04:01","9/8/2015 06:59","10/8/2015 22:43","11/8/2015 01:58","12/7/2015 18:53",
};
        public static void GetnGanZhi()
        {
            int year, year1, year2;
            year = GuaZhu.nQiGuaYear;
            if (GuaZhu.nQiGuaMonth == 1)
            {
                year -= 1;
            }
            else if (GuaZhu.nQiGuaMonth == 2)
            {
                DateTime lichun, birthday1;
                lichun = DateTime.Parse("2012-2-4 18:22");
                string birthday2;
                switch (GuaZhu.nQiGuaYear - 2012)
                {
                    case 0:
                        lichun = DateTime.Parse("2012-2-4 18:22");
                        break;
                    case 1:
                        lichun = DateTime.Parse("2013-2-4 00:13");
                        break;
                    case 2:
                        lichun = DateTime.Parse("2014-2-4 06:03");
                        break;
                    case 3:
                        lichun = DateTime.Parse("2015-2-4 11:58");
                        break;
                }
                birthday2 = GuaZhu.nQiGuaYear + "-" + GuaZhu.nQiGuaMonth + "-" + GuaZhu.nQiGuaDay + " " + GuaZhu.nQiGuaHour + ":" + GuaZhu.nQiGuaMinute;
                birthday1 = DateTime.Parse(birthday2);
                if (birthday1 < lichun)
                {
                    year -= 1;
                }
            }
            year1 = year % 10 < 4 ? (year % 10 + 10) : year % 10;
            year2 = year % 12 < 4 ? (year % 12 + 12) : year % 12;
            nTianGan = TianGan[year1 - 4];
            nDiZhi = DiZhi[year2 - 4];
        }
        public static void GetYueGan()
        {
            yTianGanID = nTianGanID * 2 + JieQiMonth + 1;
            if ((yTianGanID >= 10) && (yTianGanID < 20))
            {
                yTianGanID -= 10;
            }
            else if (yTianGanID >= 20)
            {
                yTianGanID -= 20;
            }
            if (yTianGanID == 10)
            {
                yTianGanID = 0;
            }
            yTianGan = TianGan[yTianGanID];
        }
        public static void GetyGanZhi()
        {
            string sJieQiName1 = "", sJieQiName2 = "";
            string birthday2;
            birthday2 = GuaZhu.nQiGuaYear + "-" + GuaZhu.nQiGuaMonth + "-" + GuaZhu.nQiGuaDay + " " + GuaZhu.nQiGuaHour + ":" + GuaZhu.nQiGuaMinute;
            DateTime date = DateTime.Parse(birthday2);
            for (int i = 46; i > -1; i--)
            {
                if ((i + 1) % 12 > 8)
                {
                    PrevJQYear = JieQi[i + 1].Substring(5, 4);
                    PrevJQMonth = JieQi[i + 1].Substring(0, 2);
                    PrevJQDay = JieQi[i + 1].Substring(3, 1);
                }
                else
                {
                    PrevJQYear = JieQi[i + 1].Substring(4, 4);
                    PrevJQMonth = JieQi[i + 1].Substring(0, 1);
                    PrevJQDay = JieQi[i + 1].Substring(2, 1);
                }
                PrevJQHour = JieQi[i + 1].Substring(JieQi[i + 1].Length - 5, 2);
                PrevJQMinute = JieQi[i + 1].Substring(JieQi[i + 1].Length - 2, 2);
                PrevJieQi = PrevJQYear + "-" + PrevJQMonth + "-" + PrevJQDay + " " + PrevJQHour + ":" + PrevJQMinute;
                if (i % 12 > 8)
                {
                    NextJQYear = JieQi[i].Substring(5, 4);
                    NextJQMonth = JieQi[i].Substring(0, 2);
                    NextJQDay = JieQi[i].Substring(3, 1);
                }
                else
                {
                    NextJQYear = JieQi[i].Substring(4, 4);
                    NextJQMonth = JieQi[i].Substring(0, 1);
                    NextJQDay = JieQi[i].Substring(2, 1);
                }
                NextJQHour = JieQi[i].Substring(JieQi[i].Length - 5, 2);
                NextJQMinute = JieQi[i].Substring(JieQi[i].Length - 2, 2);
                NextJieQi = NextJQYear + "-" + NextJQMonth + "-" + NextJQDay + " " + NextJQHour + ":" + NextJQMinute;
                DateTime date2 = DateTime.Parse(NextJieQi);
                if (date >= date2)
                {
                    switch (i % 12)
                    {
                        case 1:
                            sJieQiName1 = "立春:";
                            sJieQiName2 = "惊蛰:";
                            JieQiMonth = 1;
                            break;
                        case 2:
                            sJieQiName1 = "惊蛰:";
                            sJieQiName2 = "清明:";
                            JieQiMonth = 2;
                            break;
                        case 3:
                            sJieQiName1 = "清明:";
                            sJieQiName2 = "立夏:";
                            JieQiMonth = 3;
                            break;
                        case 4:
                            sJieQiName1 = "立夏:";
                            sJieQiName2 = "芒种:";
                            JieQiMonth = 4;
                            break;
                        case 5:
                            sJieQiName1 = "芒种:";
                            sJieQiName2 = "小暑:";
                            JieQiMonth = 5;
                            break;
                        case 6:
                            sJieQiName1 = "小暑:";
                            sJieQiName2 = "立秋:";
                            JieQiMonth = 6;
                            break;
                        case 7:
                            sJieQiName1 = "立秋:";
                            sJieQiName2 = "白露:";
                            JieQiMonth = 7;
                            break;
                        case 8:
                            sJieQiName1 = "白露:";
                            sJieQiName2 = "寒露:";
                            JieQiMonth = 8;
                            break;
                        case 9:
                            sJieQiName1 = "寒露:";
                            sJieQiName2 = "立冬:";
                            JieQiMonth = 9;
                            break;
                        case 10:
                            sJieQiName1 = "立冬:";
                            sJieQiName2 = "大雪:";
                            JieQiMonth = 10;
                            break;
                        case 11:
                            sJieQiName1 = "大雪:";
                            sJieQiName2 = "小寒:";
                            JieQiMonth = 11;
                            break;
                        case 0:
                            sJieQiName1 = "小寒:";
                            sJieQiName2 = "立春:";
                            JieQiMonth = 12;
                            break;
                    }
                    PrevJieQi = sJieQiName2 + PrevJQYear + "年" + PrevJQMonth + "月" + PrevJQDay + "日" + PrevJQHour + "时" + PrevJQMinute + "分";
                    NextJieQi = sJieQiName1 + NextJQYear + "年" + NextJQMonth + "月" + NextJQDay + "日" + NextJQHour + "时" + NextJQMinute + "分";
                    break;
                }
            }
            switch (nTianGan)
            {
                case "甲":
                    nTianGanID = 0;
                    GetYueGan();
                    break;
                case "乙":
                    nTianGanID = 1;
                    GetYueGan();
                    break;
                case "丙":
                    nTianGanID = 2;
                    GetYueGan();
                    break;
                case "丁":
                    nTianGanID = 3;
                    GetYueGan();
                    break;
                case "戊":
                    nTianGanID = 4;
                    GetYueGan();
                    break;
                case "己":
                    nTianGanID = 5;
                    GetYueGan();
                    break;
                case "庚":
                    nTianGanID = 6;
                    GetYueGan();
                    break;
                case "辛":
                    nTianGanID = 7;
                    GetYueGan();
                    break;
                case "壬":
                    nTianGanID = 8;
                    GetYueGan();
                    break;
                case "癸":
                    nTianGanID = 9;
                    GetYueGan();
                    break;
            }
            if (JieQiMonth <= 10)
            {
                yDiZhi = DiZhi[JieQiMonth + 1];
            }
            else if (JieQiMonth == 11)
            {
                JieQiMonth = 0;
                yDiZhi = DiZhi[JieQiMonth];
            }
            else
            {
                JieQiMonth = 1;
                yDiZhi = DiZhi[JieQiMonth];
            }
        }
        public static void GetrGanZhi()
        {
            DateTime baseDate = new DateTime(2000, 1, 1);
            DateTime qiguaDate = new DateTime(GuaZhu.nQiGuaYear, GuaZhu.nQiGuaMonth, GuaZhu.nQiGuaDay);
            TimeSpan ts = qiguaDate - baseDate;
            int gapdays = ts.Days;
            if (GuaZhu.nQiGuaHour == 23)
            {
                gapdays += 1;
            }
            if (gapdays >= 6)
            {
                rTianGan = TianGan[(gapdays - 6) % 10];
                rDiZhi = DiZhi[(gapdays - 6) % 12];
            }
            else if (gapdays < 0)
            {
                gapdays = gapdays * (-1);
                rTianGan = TianGan[(gapdays + 6) % 10];
                rDiZhi = DiZhi[(gapdays + 6) % 12];
            }
            else
            {
                switch (gapdays)
                {
                    case 0:
                        rTianGan = "戊";
                        rDiZhi = "午";
                        break;
                    case 1:
                        rTianGan = "己";
                        rDiZhi = "未";
                        break;
                    case 2:
                        rTianGan = "庚";
                        rDiZhi = "申";
                        break;
                    case 3:
                        rTianGan = "辛";
                        rDiZhi = "酉";
                        break;
                    case 4:
                        rTianGan = "壬";
                        rDiZhi = "戌";
                        break;
                    case 5:
                        rTianGan = "癸";
                        rDiZhi = "亥";
                        break;
                }
            }
        }
        public static void GetShiGan()
        {
            if (GuaZhu.nQiGuaHour == 23 || GuaZhu.nQiGuaHour == 0)
            {
                rTianGanID = 0 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 1 || GuaZhu.nQiGuaHour == 2)
            {
                rTianGanID = 1 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 3 || GuaZhu.nQiGuaHour == 4)
            {
                rTianGanID = 2 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 5 || GuaZhu.nQiGuaHour == 6)
            {
                rTianGanID = 3 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 7 || GuaZhu.nQiGuaHour == 8)
            {
                rTianGanID = 4 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 9 || GuaZhu.nQiGuaHour == 10)
            {
                rTianGanID = 5 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 11 || GuaZhu.nQiGuaHour == 12)
            {
                rTianGanID = 6 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 13 || GuaZhu.nQiGuaHour == 14)
            {
                rTianGanID = 7 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 15 || GuaZhu.nQiGuaHour == 16)
            {
                rTianGanID = 8 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 17 || GuaZhu.nQiGuaHour == 18)
            {
                rTianGanID = 9 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 19 || GuaZhu.nQiGuaHour == 20)
            {
                rTianGanID = 10 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
            else if (GuaZhu.nQiGuaHour == 21 || GuaZhu.nQiGuaHour == 22)
            {
                rTianGanID = 11 + rTianGanID;
                rTianGanID = rTianGanID > 9 ? (rTianGanID - 10) : rTianGanID;
                sTianGan = TianGan[rTianGanID];
            }
        }
        public static void GetsGanZhi()
        {
            if (rTianGan == "甲" || rTianGan == "己")
            {
                rTianGanID = 0;
                GetShiGan();
            }
            else if (rTianGan == "乙" || rTianGan == "庚")
            {
                rTianGanID = 2;
                GetShiGan();
            }
            else if (rTianGan == "丙" || rTianGan == "辛")
            {
                rTianGanID = 4;
                GetShiGan();
            }
            else if (rTianGan == "丁" || rTianGan == "壬")
            {
                rTianGanID = 6;
                GetShiGan();
            }
            else
            {
                rTianGanID = 8;
                GetShiGan();
            }
            if (GuaZhu.nQiGuaHour == 23 || GuaZhu.nQiGuaHour == 0)
            {
                sDiZhi = DiZhi[0];
            }
            if (GuaZhu.nQiGuaHour == 1 || GuaZhu.nQiGuaHour == 2)
            {
                sDiZhi = DiZhi[1];
            }
            if (GuaZhu.nQiGuaHour == 3 || GuaZhu.nQiGuaHour == 4)
            {
                sDiZhi = DiZhi[2];
            }
            if (GuaZhu.nQiGuaHour == 5 || GuaZhu.nQiGuaHour == 6)
            {
                sDiZhi = DiZhi[3];
            }
            if (GuaZhu.nQiGuaHour == 7 || GuaZhu.nQiGuaHour == 8)
            {
                sDiZhi = DiZhi[4];
            }
            if (GuaZhu.nQiGuaHour == 9 || GuaZhu.nQiGuaHour == 10)
            {
                sDiZhi = DiZhi[5];
            }
            if (GuaZhu.nQiGuaHour == 11 || GuaZhu.nQiGuaHour == 12)
            {
                sDiZhi = DiZhi[6];
            }
            if (GuaZhu.nQiGuaHour == 13 || GuaZhu.nQiGuaHour == 14)
            {
                sDiZhi = DiZhi[7];
            }
            if (GuaZhu.nQiGuaHour == 15 || GuaZhu.nQiGuaHour == 16)
            {
                sDiZhi = DiZhi[8];
            }
            if (GuaZhu.nQiGuaHour == 17 || GuaZhu.nQiGuaHour == 18)
            {
                sDiZhi = DiZhi[9];
            }
            if (GuaZhu.nQiGuaHour == 19 || GuaZhu.nQiGuaHour == 20)
            {
                sDiZhi = DiZhi[10];
            }
            if (GuaZhu.nQiGuaHour == 21 || GuaZhu.nQiGuaHour == 22)
            {
                sDiZhi = DiZhi[11];
            }
        }
        public static void GetSiZhu()
        {
            GetnGanZhi();
            GetyGanZhi();
            GetrGanZhi();
            GetsGanZhi();
            sSiZhu = nTianGan + nDiZhi + " " + yTianGan + yDiZhi + " ";
            sSiZhu += rTianGan + rDiZhi + " " + sTianGan + sDiZhi;
            string birthday;
            birthday = nQiGuaYear + "年" + nQiGuaMonth + "月" + nQiGuaDay + "日" + nQiGuaHour + "时" + nQiGuaMinute + "分";
            Console.WriteLine("公历出生时间:" + birthday);
            Console.WriteLine("前一节气是" + NextJieQi);
            Console.WriteLine("后一节气是" + PrevJieQi);
            Console.WriteLine("命主生辰八字是:" + sSiZhu);
            Console.WriteLine("请按任意键继续...");
            Console.ReadKey();
        }
    }
}

以上就是本文给大家分享的代码的全部内容了,希望大家能够喜欢,能够对大家学习C#有所帮助。

(0)

相关推荐

  • C#实现根据年份计算生肖属相的方法

    本文实例讲述了C#实现根据年份计算生肖属相的方法.分享给大家供大家参考.具体分析如下: 提供年份可以输出属相,代码比较简单,因为2008年为鼠年,所以程序以2008为标准开始,2008对中国人也有特殊的意义 private static void shuxiang(int year) { string[] shuxiang = {"鼠","牛","虎","兔","龙","蛇","

  • C#和SQL实现的字符串相似度计算代码分享

    C#实现: 复制代码 代码如下: #region 计算字符串相似度         /// <summary>         /// 计算字符串相似度         /// </summary>         /// <param name="str1">字符串1</param>         /// <param name="str2">字符串2</param>         ///

  • C#计算文件MD5校验的方法

    本文实例讲述了C#计算文件MD5校验的方法.分享给大家供大家参考.具体分析如下: C#计算文件的MD5校验,从互联网上下载一个文件,可以使用下面的代码对文件进行MD5校验,看看生成的MD5编码是否和网站提供的一致,如果不一致则表示文件被修改过了,要慎重. protected string GetMD5HashFromFile(string fileName) { FileStream file = new FileStream(fileName,FileMode.Open); MD5 md5 =

  • C# 实现计算生辰八字

    Form1.cs 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 BrithdayEigth { public partial class Form1 : F

  • C#基于基姆拉尔森算法计算指定日期是星期几的方法

    本文实例讲述了C#基于基姆拉尔森算法计算指定日期是星期几的方法.分享给大家供大家参考.具体分析如下: 基姆拉尔森计算公式 W= (d+2*m+3*(m+1)/5+y+y/4-y/100+y/400) mod 7 在公式中d表示日期中的日数,m表示月份数,y表示年数. 注意:在公式中有个与其他公式不同的地方: 把一月和二月看成是上一年的十三月和十四月,例:如果是2004-1-10则换算成:2003-13-10来代入公式计算. #region 根据年月日计算星期几(lblDate.Text=Cacu

  • C#使用linq计算执行元素在列表中出现次数的方法

    本文实例讲述了C#使用linq计算执行元素在列表中出现次数的方法.分享给大家供大家参考.具体如下: 这是使用linq计算元素在列表中出现的次数,调用方法非常简单,和sql语句很像 复制代码 代码如下: // Count the number of times an item appears in this list public static int CountTimes<T>(this List<T> inputList, T searchItem) { return ((fro

  • C#精确计算年龄的方法分析

    本文实例讲述了C#精确计算年龄的方法.分享给大家供大家参考.具体如下: 该源码在vs2010测试通过 复制代码 代码如下: using System; using System.Collections.Generic; using System.Text; namespace PublicClass {     public static class CalculationDate     {         /// <summary>         /// 由两个日期计算出年龄(岁.月.天

  • C#开发的人脸左右相似度计算软件源码分析

    本文实例讲述了C#开发的人脸左右相似度计算软件.分享给大家供大家参考.具体分析如下: 模仿湖南卫视快乐大本营中所使用的一款人脸左右对称相似度计算软件,自己写的一个小软件,使用语言是C#,希望跟喜欢这个软件的同志们共享! 1. FaceClass类程序 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; using System.Dra

  • C#检测远程计算机端口是否打开的方法

    本文实例讲述了C#检测远程计算机端口是否打开的方法.分享给大家供大家参考.具体分析如下: 这段C#代码用于检测远程计算机的3389端口是否处理打开状态,可以根据实际需要设置其它端口 using System; using System.Collections.Generic; using System.Text; using System.Net.NetworkInformation; namespace test { class Program { static void Main(strin

  • C#编写的生辰八字计算程序

    作者故意删除了注释,读不懂代码的,就加作者QQ721159175咨询吧,作者很乐意与你分享并解答~ 复制代码 代码如下: using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 {     class Program     {         static void Main(string[] args)         {             //假设

  • 编写xml没有代码提示的解决方法

    有时候在编写 struts.xml 会没有代码提示,一般是因为没有联网导致的,或者之前配置过 dtd 文件 url,但是文件路径之后被修改了. 解决方案有: 让电脑联网 修改 dtd 的本地路径以及 url 第二种的步骤如下: Window-->>Preferences 搜索 : xml catalog -->>Add 勾选 workspace -->选择本地 dtd 文件的 Location --->>Key type 选择 URI 点击 OK 即可. 以上这篇

  • hta文件介绍(编写小程序的好东东)

    总是想用script语言编写一些小程序,以前总是写成html格式的,可每次打开都会有安全提示,今天突然发现了如果保存成hta格式的文件,效果大不一样. 嘿嘿.. HTA是HTML Application的缩写(HTML应用程序),是软件开发的新概念,直接将HTML保存成HTA的格式,就是一个独立的应用软件,与VB.C++等程序语言所设计的软件没什么差别. 下面是一个HTA的例子: 复制代码 代码如下: <!-example1.hta--><html><head><

  • BAT文件语法和技巧(bat文件的编写及使用)

    BAT文件语法和技巧(bat文件的编写及使用)(转载一) 比较有用的东比较有用的东西  首先,批处理文件是一个文本文件,这个文件的每一行都是一条DOS命令(大部分时候就好象我们在DOS提示符下执行的命令行一样),你可以使用DOS下的Edit或者Windows的记事本(notepad)等任何文本文件编辑工具创建和修改批处理文件.    其次,批处理文件是一种简单的程序,可以通过条件语句(if)和流程控制语句(goto)来控制命令运行的流程,在批处理中也可以使用循环语句(for)来循环执行一条命令.

  • JavaScript的ExtJS框架中表格的编写教程

    ExtJS中表格的特性简介 表格由类Ext.grid.GridPanel定义,继承自Ext.Panel,xtype为grid 表格的列信息由Ext.grid.ColumnModel定义 表格的数据存储器由Ext.data.Store定义,根据解析数据的不同,数据存储器可具体分为如下几种: JsonStore,SimpleStore,GroupingStore- 一个表格的基本编写过程: 1.创建表格列模型 var cm = new Ext.grid.ColumnModel({ {header:

  • 利用Angular.js编写公共提示模块的方法教程

    前言 在编写一些大型工程的时候,会经常遇到一些公用提示,使用框架自带很多时候不方便,于是我手写了一个,下面来看看详细的介绍: 效果图如下 方法如下 一.先在angular中注册一个模块 二. 注册一个模块 注入依赖 三. 返回不同的方法应对不同情况 四. 获取模板路径 五. 编写模板内容 和普通的页面一样调用使用angular服务 六. 1. 开启http服务获取模板内容 2.  重点注意 $template = $compile(template)(scope); 这句代码非常重要  用于激活

  • 使用AngularJS编写多选按钮选中时触发指定方法的指令代码详解

    最近在做项目时,遇到了需要用到多选按钮选中触发事件的功能,因此我查找了一下AngularJS的提供的指令,但是没有发现相应的指令.而一个看起来很像的指令就是ng-checked,但是这个指令是用来代替标签里面checked属性的,所以也用不了.因此我就自己动手试着写一个这样的指令,相应的代码如下: <form name="test_form" ng-controller="TestCtrl"> <input type="checkbox&

  • 正则表达式创建方式的区别及编写简单的正则方式(js学习总结)

    在字面量方式中,我们//之间包起来的所有的内容都是元字符,有的具有特殊意义,大部分都是代表本身含义的普通的元字符 var name = 'wo'; var reg = /^\d+"+name+"\d+$/ 为了解决上述想在正则里面加上一个变量这样的需求,我们只能使用实例创建的方式了 var reg = new RegExp("^\\d+"+name+"\\d+$","g") 字面量方式和实例创建的方式在正则中的区别? 1.字面

  • Python Nose框架编写测试用例方法

    1. 关于Nose nose项目是于2005年发布的,也就是 py.test改名后的一年.它是由 Jason Pellerin 编写的,支持与 py.test 相同的测试习惯做法,但是这个包更容易安装和维护. nose的口号是:扩展unittest,nose让测试更简单! nose官网:http://nose.readthedocs.io/en/latest/index.html 使用nose框架进行Python项目的自动化测试,可以参考:http://www.cnblogs.com/liaof

  • JavaScript编写一个简易购物车功能

    网上关于购物车实现的代码非常多,今天看了一些知识点,决定自己动手写写,于是写了一个简易购物车,接下来讲解一下具体的实现. 1.用html实现内容: 2.用css修饰外观: 3.用js(jq)设计动效. 第一步:首先是进行html页面的设计,我用一个大的div将所有商品包含,然后用不同的div将不同的商品进行封装,商品列表中我用了ul li实现,具体实现代码如下(代码中涉及到的商品都是网上随便copy的,不具有参考价值): <div id="goods"> <div c

随机推荐