お知らせ

VB6関数一覧

    public static class VB6Function
    {
        #region 変換関数

        #region Asc
        #endregion

        #region AscW
        #endregion

        #region CBool 関数
        #endregion

        #region CByte 関数
        #endregion

        #region CChar 関数
        #endregion

        #region CDate 関数
        #endregion

        #region CDbl 関数
        #endregion

        #region CDec 関数
        #endregion

        #region Chr
        #endregion

        #region ChrW
        #endregion

        #region CInt 関数
        #endregion

        #region CLng 関数
        #endregion

        #region CObj 関数
        #endregion

        #region CSByte 関数
        #endregion

        #region CShort 関数
        #endregion

        #region CSng 関数
        #endregion

        #region CStr 関数
        #endregion

        #region CType 関数
        #endregion

        #region CUInt 関数
        #endregion

        #region CULng 関数
        #endregion

        #region CUShort 関数
        #endregion

        #region Format
        #endregion

        #region Hex
        #endregion

        #region Oct
        #endregion

        #region Str
        #endregion

        #region Val
        #endregion

        #endregion

        #region 数値演算関数
        #endregion

        #region 文字列関数
        #endregion

        #region データ型変換関数

        #region CBool
        /// <summary>
        /// CBool
        /// </summary>
        /// <param name="expression">値</param>
        /// <returns>Bool</returns>
        public bool CBool(object expression)
        {
            switch (CStr(expression).Trim().ToLower())
            {
                case "true":
                case "1":
                    return true;
                default:
                    return false;
            }
        }
        #endregion

        #region CByte
        /// <summary>
        /// CByte
        /// </summary>
        /// <param name="expression">値</param>
        /// <returns>Byte</returns>
        public byte CByte(object expression)
        {
            byte result;
            byte.TryParse(CStr(expression).Trim(), out result);
            return result;
        }
        #endregion

        #region CChar
        /// <summary>
        /// CChar
        /// </summary>
        /// <param name="expression">値</param>
        /// <returns>Char</returns>
        public char CChar(object expression)
        {
            char result;
            char.TryParse(CStr(expression).Trim(), out result);
            return result;
        }
        #endregion

        #region CDate
        /// <summary>
        /// CDate
        /// </summary>
        /// <param name="expression">値</param>
        /// <returns>Date</returns>
        public DateTime CDate(object expression)
        {
            DateTime result;
            DateTime.TryParse(CStr(expression).Trim(), out result);
            return result;
        }
        #endregion

        #region CDbl
        /// <summary>
        /// CDbl
        /// </summary>
        /// <param name="expression">値</param>
        /// <returns>Dbl</returns>
        public double CDbl(object expression)
        {
            double result;
            double.TryParse(CStr(expression).Trim(), out result);
            return result;
        }
        #endregion

        #region CDec
        /// <summary>
        /// CDec
        /// </summary>
        /// <param name="expression">値</param>
        /// <returns>Dec</returns>
        public decimal CDec(object expression)
        {
            decimal result;
            decimal.TryParse(CStr(expression).Trim(), out result);
            return result;
        }
        #endregion

        #region CInt
        /// <summary>
        /// CInt
        /// </summary>
        /// <param name="expression">値</param>
        /// <returns>Int</returns>
        public int CInt(object expression)
        {
            int result;
            int.TryParse(CStr(expression).Trim(), out result);
            return result;
        }
        #endregion

        #region CLng
        /// <summary>
        /// CLng
        /// </summary>
        /// <param name="expression">値</param>
        /// <returns>Lng</returns>
        public long CLng(object expression)
        {
            long result;
            long.TryParse(CStr(expression).Trim(), out result);
            return result;
        }
        #endregion

        #region CObj
        /// <summary>
        /// CObj
        /// </summary>
        /// <param name="expression">値</param>
        /// <returns>Obj</returns>
        public object CObj(object expression)
        {
            return expression;
        }
        #endregion

        #region CSByte
        /// <summary>
        /// CSByte
        /// </summary>
        /// <param name="expression">値</param>
        /// <returns>Byte</returns>
        public sbyte CSByte(object expression)
        {
            sbyte result;
            sbyte.TryParse(CStr(expression).Trim(), out result);
            return result;
        }
        #endregion

        #region CShort
        /// <summary>
        /// CShort
        /// </summary>
        /// <param name="expression">値</param>
        /// <returns>Short</returns>
        public short CShort(object expression)
        {
            short result;
            short.TryParse(CStr(expression).Trim(), out result);
            return result;
        }
        #endregion

        #region CSng
        /// <summary>
        /// CSng
        /// </summary>
        /// <param name="expression">値</param>
        /// <returns>Sng</returns>
        public double CSng(object expression)
        {
            return CDbl(expression);
        }
        #endregion

        #region CStr
        /// <summary>
        /// CStr
        /// </summary>
        /// <param name="expression">値</param>
        /// <returns>Str</returns>
        public string CStr(object expression)
        {
            return expression.ToString();
        }
        #endregion

        #region CUInt
        /// <summary>
        /// CUInt
        /// </summary>
        /// <param name="expression">値</param>
        /// <returns>UInt</returns>
        public uint CUInt(object expression)
        {
            uint result;
            uint.TryParse(CStr(expression).Trim(), out result);
            return result;
        }
        #endregion

        #region CULng
        /// <summary>
        /// CULng
        /// </summary>
        /// <param name="expression">値</param>
        /// <returns>ULng</returns>
        public ulong CULng(object expression)
        {
            ulong result;
            ulong.TryParse(CStr(expression).Trim(), out result);
            return result;
        }
        #endregion

        #region CUShort
        /// <summary>
        /// CUShort
        /// </summary>
        /// <param name="expression">値</param>
        /// <returns>UShort</returns>
        public ushort CUShort(object expression)
        {
            ushort result;
            ushort.TryParse(CStr(expression).Trim(), out result);
            return result;
        }
        #endregion

        #endregion

        #region CType 関数

        #region CType
        /// <summary>
        /// CType
        /// </summary>
        /// <param name="expression">値</param>
        /// <param name="typename">型</param>
        /// <returns>Type</returns>
        public object CType(object expression, string typename)
        {
            switch(typename)
            {
                case "bool":                   
                    return CBool(expression);
                case "byte":                   
                    return CByte(expression);
                case "char":
                    return CChar(expression);
                case "date":
                    return CDate(expression);
                case "double":
                    return CDbl(expression);
                case "decimal":
                    return CDec(expression);
                case "int":
                    return CInt(expression);
                case "long":
                    return CLng(expression);
                case "csbyte":
                    return CSByte(expression);
                case "short":
                    return CShort(expression);
                case "single":
                    return CSng(expression);
                case "string":
                    return CStr(expression);
                case "uint":
                    return CUInt(expression);
                case "ulong":
                    return CULng(expression);
                case "ushort":
                    return CUShort(expression);
                default:
                    return null;
            }
        }
        #endregion
    }

コメント