您的位置:程序门 -> vb ->



帮帮忙吧,怎样才能调用这段自定义函数啊


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


帮帮忙吧,怎样才能调用这段自定义函数啊[已结贴,结贴人:aeae12]
发表于:2007-10-28 13:42:18 楼主
这是一段字符串匹配的函数,在access中使用没有问题,请问在vb中怎样使用它呢,请哪位好心人给说明一下,用代码调用,改造  

函数都行,最好写段代码,我水平很烂的。不胜感激!!!  
我用adodc连接access  
access中执行语句:  
select   *   from   comparebase   inner   join   zd_wc2   on   alikepercentex(comparebase.xm_name,zd_wc2.wc_name)  

函数  

public   function   alikepercentex(byval   strtextsrc   as   string,   _      
                                                                                                                        byval   strtextdest   as   string,   _      
                                                                                                                        optional   byval   blncasesensitive   as   boolean   =   false,   _      
                                                                                                                        optional   byval   blnexactpositionmatch   as   boolean   =   false)   as   double      
                             
                    dim   o_strtextsrc           as   string      
                    dim   o_strtextdest           as   string        
                    dim   o_strtextlonger           as   string      
                    dim   o_strtextshorter           as   string      
                             
                    dim   o_strbytesrc           as   string      
                    dim   o_strbytedest           as   string      
                    dim   o_lnglength           as   long      
                    dim   o_lngitems           as   long      
                    dim   o_lngmatches           as   long      
                    dim   o_lngstart           as   long      
                             
                    if   not   blncasesensitive   then      
                                    o_strtextsrc   =   ucase(strtextsrc)      
                                    o_strtextdest   =   ucase(strtextdest)      
                    else      
                    end   if            
                    if   o_strtextsrc   =   o_strtextdest   then                             '如果一致                  
                                    alikepercentex   =   100#      
                    else      
                                    if   len(o_strtextsrc)   =   len(o_strtextdest)   then      
                                                    o_strtextlonger   =   o_strtextsrc      
                                                    o_strtextshorter   =   o_strtextdest      
                                    elseif   len(o_strtextsrc)         >   len(o_strtextdest)   then      
                                                    o_strtextlonger   =   o_strtextsrc      
                                                    o_strtextshorter   =   o_strtextdest      
                                    else      
                                                    o_strtextlonger   =   o_strtextdest      
                                                    o_strtextshorter   =   o_strtextsrc      
                                    end   if                                              
                                    o_lnglength   =   len(o_strtextshorter)      
                                    o_lngstart   =   instr(o_strtextlonger,   left(o_strtextshorter,   1))        
                                    if   o_lngstart   then      
                                                    o_lngmatches   =   1      
                                                    for   o_lngitems   =   o_lngstart   +   1   to   len(o_strtextlonger)                            
                                                                    if   blnexactpositionmatch   then                     '位置必须一致      
                                                                                    o_strbytesrc   =   mid(o_strtextlonger,   o_lngitems,   1)      
                                                                                    o_strbytedest   =   mid(o_strtextshorter,   o_lngitems   -   o_lngstart   +   1,   1)                      
                                                                                    if   o_strbytesrc   =   o_strbytedest   then      
                                                                                                    o_lngmatches   =   o_lngmatches   +   1      
                                                                                    else      
                                                                                    end   if      
                                                                    else             '任意位置模糊匹配                
                                                                    end   if      
                                                    next      
                                                    alikepercentex   =   (o_lngmatches   /   o_lnglength)   *   100   \1    
                                    else                      
                                                  alikepercentex   =   0#      
                                    end   if                                  
                    end   if              
    end   function    


快速检索

最新资讯
热门点击