惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
L
LangChain Blog
量子位
GbyAI
GbyAI
B
Blog RSS Feed
月光博客
月光博客
人人都是产品经理
人人都是产品经理
腾讯CDC
Recent Announcements
Recent Announcements
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
The Cloudflare Blog
D
Docker
Cyberwarzone
Cyberwarzone
U
Unit 42
NISL@THU
NISL@THU
C
Check Point Blog
B
Blog
大猫的无限游戏
大猫的无限游戏
Cisco Talos Blog
Cisco Talos Blog
Recorded Future
Recorded Future
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
G
GRAHAM CLULEY
Engineering at Meta
Engineering at Meta
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
P
Proofpoint News Feed
F
Fortinet All Blogs
V
V2EX
T
Threat Research - Cisco Blogs
T
Threatpost
S
SegmentFault 最新的问题
Know Your Adversary
Know Your Adversary
雷峰网
雷峰网
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园 - 司徒正美
P
Privacy & Cybersecurity Law Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
TaoSecurity Blog
TaoSecurity Blog
Latest news
Latest news
Apple Machine Learning Research
Apple Machine Learning Research
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Y
Y Combinator Blog
P
Privacy International News Feed
L
Lohrmann on Cybersecurity
AWS News Blog
AWS News Blog
G
Google Developers Blog
美团技术团队

博客园 - 猫狼

安卓连接usb camera 安卓手机连接USB摄像头代码 安装Memurai 把“休眠”功能找回来,并设置成一合上盖子就生效 mathtype安装后在office无法启动,提示运行时错误53, 文件未找到:MathPage.WLL ASP.NET Web Site Project 中集成 Hangfire 并实现图片/视频压缩后台任务 SQL SERVER 数据库压缩日志步骤 Latex的一个错误, SQL 学习笔记 升级 ASP.NET 网站项目到 C# 6.0 或更高版本 C#程序集合并工具-ILRepack manim 安装 manim一个坑爸爸的问题 manim安装纪实 去掉快捷方式的小箭头 VS2022转到定义功能异常解决方案 url 传递加号,asp.net解析参数的正确处理参数 获取自然周数的下拉列表 移出Json对象的三级属性 梦记:又要去交流? 多个AJAX请求,带执行进度及结果 C# 返回文件夹及子目录 解决JS跨域访问的问题 利用Jquery的map函数将json数据行转化为表格 模访京东商城jQuery省市区三级联动选择(横向DIV)
一段VBA的代码,到处是坑
猫狼 · 2024-07-24 · via 博客园 - 猫狼

VBA不太会,要写一个题号检查的代码,实在不习惯反人类的语法格式,函数调用不打括号,返回值为函数等于,字符编码不一样,Find.Excute不支持变量,等等……每一个都让人抓耳挠腮,

记录一下半天,就写了下面几行代码,

'检查题号 2024-07-24
Sub CheckOrderNo()
    Dim text As String
    Dim cnt As Integer
    cnt = 0
    text = "【解析】"
    With ActiveDocument.Content.Find
        Do While .Execute(FindText:=text) = True
            cnt = cnt + 1
        Loop
    End With
    Dim i As Integer
    Dim t As Integer
    Dim no As String
    Dim repeat As String
    For i = 0 To cnt Step 1
        no = Str(i) & ""
        t = CountString(no)
        If (t > 1) Then
            repeat = repeat + "" + Str(i) + "题有" + Str(t) + "个;" + (Chr(13) & Chr(10))
        End If
    Next i
    If (Len(repeat) > 1) Then
        MsgBox repeat, vbOKOnly, "XMATH消息提示"
    Else
        repeat = "共[" + Str(cnt) + "]题,检查通过!"
        MsgBox repeat, vbOKOnly, "XMATH消息提示"
    End If
End Sub


'检查题号是否有重复2024-07-24
Function CountString(text As String) As Integer
    Dim Reg As New VBScript_RegExp_55.regexp
    Dim MC As VBScript_RegExp_55.MatchCollection
    Dim M As VBScript_RegExp_55.Match
    Dim Source As String
    Selection.WholeStory
    Source = Selection.text
    Dim oldTex As String
    Dim count As Integer
    count = 0
    With Reg
        .Global = True
        .Pattern = "\d+."
        Set MC = .Execute(Source)
        For Each M In MC
            oldTex = CStr(M.Value)
            If StrConv(Trim(M.Value), vbUnicode) = StrConv(Trim(text), vbUnicode) Then
                count = count + 1
            End If
        Next M
    End With
    CountString = count
End Function