推荐.NET教程: ASP.NET C# 开发环境 Ajax教程 控件开发 统计报表 数据库 Web服务 安装部署 CommunityServer NHibernate DataGrid/GridView 实用代码 VS2005
示例源码 MVC/三层 SqlHelper 入门源码 开源 CMS Ajax/Atlas C#.net 毕业设计 源码 经典代码 商业 本站作品 持久层 随书源码 WebService 英文/汉化 Asp.net2.0

阿牛·乐园

每天进步一点点

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  71 随笔 :: 14 文章 :: 369 评论 :: 13 Trackbacks

2007年8月13日 #

  近几日,我的工作是录入更正的农业直补农户资料,涉及到了各包村干部上报的各种样式的报表,经会计清点后,由我来统一按上报的格式来摘抄到上报表中。据会计说,我的字写得还过得去,比小代强。
  我建议用计算机来处理,打字比写字可快多了,还清楚。
  下面的工作,就是录入一大堆的编号和身份证号以及姓名。姓名不是难事,在录入几十个后,我越发的想去上网,把读霸安装上,我打它来读,这样就不用抬头看屏幕了。想到乡里网吧的半个小时打开一封邮件的速度呀,我还是放弃了。
  身份证可是不能再错误了,幸好我的电子书里有一段关于身份证格式的说明和程序,在稍加修改后,它已经可以用来批量的判断身份证是不是有格式(包括长度,出生年月,验证位)的错误。
  本想通过数据有效性来作,只是公式里不能调用VBA的函数,真是郁闷。
 
  下次有机会,改写一个公式来判断的。
 
 
Sub 检验选定区域身份证()
'
'
 检验身份证 Macro
'
 用于检测身份证号码是否正确
'
'
 快捷键: Ctrl+q
'
Dim arange As range
Dim acell As range
Dim ret As Integer
Set arange = Selection
For Each acell In arange.Cells
  
'MsgBox ActiveCell.Text
    ret = IDCheck(UCase(acell.Text))
    
If ret <> 0 Then
        acell.Select
        
MsgBox "请检查当前选定单元格的身份证是否正确", , "提示"
        
Exit Sub
    
End If
    
    
Next
    
MsgBox "全部正确", , "提示"
End Sub
Function CurrentIdCheck() As Integer
Dim ret As Integer
'MsgBox ActiveCell.Text
'
ret = IDCheck(ActiveCell.Text)
'
MsgBox ret
'
CurrentIdCheck = ret
CurrentIdCheck = 0
End Function
Function IDCheck(ByVal e As StringAs Integer
 
Dim arrVerifyCode
 
Dim Wi
 
Dim Checker
 
Dim BirthDay
 IDCheck 
= 0 '验证通过时返回
 arrVerifyCode = Split("1,0,X,9,8,7,6,5,4,3,2"",")
 Wi 
= Split("7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2"",")
 Checker 
= Split("1,9,8,7,6,5,4,3,2,1,1"",")
 
If Len(e) < 15 Or Len(e) = 16 Or Len(e) = 17 Or Len(e) > 18 Then
 
'IDCheck= "身份证号必须是15位数或18位数!"
 IDCheck = 1
 
Exit Function
 
End If
 
Dim Ai As String
 
If Len(e) = 18 Then
 Ai 
= Mid(e, 117)
 
ElseIf Len(e) = 15 Then
 Ai 
= CStr(e)
 Ai 
= Left(Ai, 6& "19" & Mid(Ai, 79)
 
End If
 
If Not IsNumeric(Ai) Then
 
'IDCheck= "身份证除最后一位外,必须为数字!"
 IDCheck = 2
 
Exit Function
 
End If
 
Dim strYear As Integer
 
Dim strMonth As Integer
 
Dim strDay As Integer
 strYear 
= CInt(Mid(Ai, 74))
 strMonth 
= CInt(Mid(Ai, 112))
 strDay 
= CInt(Mid(Ai, 132))
 BirthDay 
= Trim(strYear) + "-" + Trim(strMonth) + "-" + Trim(strDay)
 
If IsDate(BirthDay) Then
 
If DateDiff("yyyy"Now(), CDate(BirthDay)) < -140 Or CDate(BirthDay) > Now() Then
 
'IDCheck= "身份证输入错误(日期输入错误)!"
 IDCheck = 3
 
Exit Function
 
End If
 
If strMonth > 12 Or strDay > 31 Then
 
'IDCheck= "身份证输入错误(日期输入错误)!"
 IDCheck = 3
 
Exit Function
 
End If
 
Else
 
'IDCheck= "身份证输入错误(日期输入错误)!"
 IDCheck = 3
 
Exit Function
 
End If
 
Dim i As Integer
 
Dim TotalmulAiWi As Integer
 
For i = 0 To 16
 TotalmulAiWi 
= TotalmulAiWi + CInt(Mid(Ai, i + 11)) * CInt(Wi(i))
 
Next
 
Dim modValue As Integer
 modValue 
= TotalmulAiWi Mod 11
 
Dim strVerifyCode ' As Object
 strVerifyCode = arrVerifyCode(modValue)
 Ai 
= Ai & strVerifyCode
 
If Len(e) = 18 And CStr(e) <> Ai Then
 
'IDCheck= "身份证号码输入错误(身份证包含有非法字符)!"
 IDCheck = 4
 
Exit Function
 
End If
 
End Function
posted @ 2008-05-13 13:51 阿牛 阅读(107) | 评论 (1)编辑

     摘要: <!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN"><html><head><title>Untitled</title><styletype="text/css">.focus{}{background:#ffcc00;}.menu{}{color:red;}<...  阅读全文
posted @ 2008-03-04 09:04 阿牛 阅读(157) | 评论 (0)编辑

     摘要: 三行两列DIV布局之左固定宽度  阅读全文
posted @ 2007-12-21 15:57 阿牛 阅读(95) | 评论 (0)编辑

     摘要: XP的SN  阅读全文
posted @ 2007-12-09 12:15 阿牛| 编辑

     摘要: 没有想到,上个随笔的代码在POS机上出错,查了半天,如果去掉malloc和free,就没有事了。
所以,把现在的不用动态内存分配的算法记录下
  阅读全文
posted @ 2007-11-13 14:38 阿牛 阅读(181) | 评论 (1)编辑

     摘要: C#与C程序通讯时,为了数据安全,要对数据进行DES_cbc_pkcs7加密,这是C的实现
  阅读全文
posted @ 2007-11-12 15:54 阿牛 阅读(124) | 评论 (1)编辑

    建立步骤如下:
    一. 建立一个 State Machine Workflow Library ,命名为StateLib. 完成后,修改文件WorkFlow1为WF_Login
    二. 在里面通过设计器,加入下面的工作流(具体如何设计,不再说明),最终结果如图:
        



    三. 把工作流发布成WebService,VS2005会自动命名为:StateLib_WebService

    四. 添加一个新WebSite项目,命名WorkflowSite. 在Default.aspx中添加输入框,以及按钮
    五. 编写事件,测试一下

     工程下载http://www.cnblogs.com/Files/evlon/Workflow.rar
posted @ 2007-09-12 14:24 阿牛 阅读(751) | 评论 (2)编辑

    public partial class Form1 : Form
    
{
        
public Form1()
        
{
            InitializeComponent();
        }


        
private void Form1_Load(object sender, EventArgs e)
        
{
            Demo d 
= new Demo();
            d.a 
= 5;
            d.b 
= 10;
            d.c 
= new byte[]{1,2,3};
            d.s 
= "123";
            
byte[] buf = RawFormatter.RawSerialize(d);

            

            MessageBox.Show(
"aaa");
            
        }

    }


    [StructLayout(LayoutKind.Sequential,Pack
=1,CharSet=CharSet.Ansi)]
    
struct Demo
    
{
        
public byte a;
        
public int b;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst 
= 3)]
        
public byte[] c;
        [MarshalAs(UnmanagedType.ByValTStr, SizeConst 
= 5)]
        
public string s;
    }


    
public class RawFormatter
    
{
        
public static byte[] RawSerialize(object anything)
        
{
            
int rawsize = Marshal.SizeOf(anything);
            IntPtr buffer 
= Marshal.AllocHGlobal(rawsize);
            Marshal.StructureToPtr(anything, buffer, 
false);
            
byte[] rawdatas = new byte[rawsize];
            Marshal.Copy(buffer, rawdatas, 
0, rawsize);
            Marshal.FreeHGlobal(buffer);
            
return rawdatas;
        }


        
public static object RawDeserialize(byte[] rawdatas, Type anytype)
        
{
            
int rawsize = Marshal.SizeOf(anytype);
            
if (rawsize > rawdatas.Length)
                
return null;
            IntPtr buffer 
= Marshal.AllocHGlobal(rawsize);
            Marshal.Copy(rawdatas, 
0, buffer, rawsize);
            
object retobj = Marshal.PtrToStructure(buffer, anytype);
            Marshal.FreeHGlobal(buffer);
            
return retobj;
        }

    }

posted @ 2007-08-22 13:55 阿牛 阅读(58) | 评论 (1)编辑

     摘要: //CppSocket.cpp:Definestheentrypointfortheconsoleapplication.//#include"stdafx.h"#include<cstdlib>#include<string>#include<algorithm>#include<iostream>#include<fstream>#i...  阅读全文
posted @ 2007-08-13 09:02 阿牛 阅读(427) | 评论 (1)编辑