VB中準確的獲得命令行參數列表的方法,
支持引號括起來的帶空格的參數
Private Sub Form_Load() 'GUI下測試 'cmd = "-a " & Chr(34) & "c:/a 1.txt" & Chr(34) & " " & Chr(34) & "d:/b c.txt" & Chr(34) 'cmd = "-r " & Chr(34) & "c:/123/a.txt" & Chr(34) & " " & "c:/123/b.txt" cmd = Trim(Command) If cmd = "" Then '語法不正確 - 參數爲空 '參數爲空的具體處理。。。。。。 Unload Me ' 不加載窗口,即不顯示 Exit Sub End If 'Args 爲得到的參數數組 Args = GetCommandLine(cmd) ' 調試 MsgBox ("Debug-Command:" & cmd) MsgBox ("Debug-ArgCount:" & UBound(Args) + 1) For I = 0 To UBound(Args) MsgBox (I & ":" & Args(I)) Next I '對參數數組Args中的參數根據需要進行校驗 '...... Unload Me ' 不加載窗口,即不顯示 End Sub ' 獲得命令行參數(最多3個參數),並將命令行參數以 Variant 類型之數組返回。 Function GetCommandLine(ByVal CmdLine As String) '聲明變量。 Dim CmdLnLen, FirstFile, SecondFile, StartPos, StrLeft '取得命令行參數。 CmdLine = Trim(CmdLine) CmdLnLen = Len(CmdLine) '取得引號中的字符串,最多兩對引號 FirstArr = GetStrBetweenQuotes(CmdLine) If FirstArr(0) = "RetCode0" Or FirstArr(0) = "RetCode1" Then GetCommandLine = StrSplit(CmdLine, " ") Exit Function Else FirstFile = FirstArr(0) '取第二對引號中的字符串 StartPos = FirstArr(1) StrLeft = Mid(CmdLine, StartPos + 1) SecondArr = GetStrBetweenQuotes(StrLeft) If SecondArr(0) = "RetCode1" Then GetCommandLine = StrSplit(CmdLine, " ") Exit Function ElseIf SecondArr(0) = "RetCode0" Then '沒有第二對引號,SecondFile就是第二次處理的字符串 SecondFile = Trim(StrLeft) Else SecondFile = SecondArr(0) End If End If '將引號中的字符串替換掉 temp = Replace(CmdLine, FirstFile, "*1") 'MsgBox ("Debug-temp:" & temp) temp = Replace(temp, SecondFile, "*2") 'MsgBox ("Debug-temp:" & temp) '到此,已經不存在引號中含有空格的情況,但仍有可能有引號 temp = Replace(CmdLine, Chr(34), "") '去掉引號 ArgArray = StrSplit(temp, " ") For I = 0 To UBound(ArgArray) ArgArray(I) = Replace(ArgArray(I), "*1", FirstFile) '還原 ArgArray(I) = Replace(ArgArray(I), "*2", SecondFile) '還原 Next I GetCommandLine = ArgArray End Function '取得一對引號中的字符串,返回一個長度爲2數組, '數組中第一個元素是引號中的字符串,第二個元素是第二個引號的位置 Private Function GetStrBetweenQuotes(ByVal src As String) As Variant Dim ResultArray(1) quote = Chr(34) FirstQuotePos = InStr(1, src, quote) 'MsgBox ("Debug-src:" & src & ",FirstQuotePos:" & FirstQuotePos) If FirstQuotePos = 0 Then '沒有引號,退出 ResultArray(0) = "RetCode0" GetStrBetweenQuotes = ResultArray() Exit Function Else '有引號,說明文件路徑中有空格 SecondQuotePos = InStr(FirstQuotePos + 1, src, quote) 'MsgBox ("Debug-src:" & src & ",SecondQuotePos:" & SecondQuotePos) If SecondQuotePos = 0 Then '沒有第二個引號,語法不正確,引號必須成對出現 ResultArray(0) = "RetCode1" GetStrBetweenQuotes = ResultArray() Exit Function Else '有第二個引號,取出第一對引號中的數據 FirstFile = Mid(src, FirstQuotePos, SecondQuotePos - FirstQuotePos + 1) End If End If ResultArray(0) = FirstFile ResultArray(1) = SecondQuotePos 'MsgBox ("Debug-ResultArray(0)(FirstFile):" & ResultArray(0) & ",ResultArray(1):" & ResultArray(1)) GetStrBetweenQuotes = ResultArray() End Function '分割參數字符串爲參數數組 Private Function StrSplit(ByVal src As String, ByVal delimiter As String) As Variant src = Trim(src) Arr = Split(src, delimiter) Dim result As String For I = 0 To UBound(Arr) j = Arr(I) If j <> "" Or j <> " " Then If result <> "" Then result = result & "," & j Else result = j End If End If Next I StrSplit = Split(result, ",") End Function
虛擬線程(Virtual Thread)也稱協程或纖程,是一種輕量級的線程實現,與傳統的線程以及操作系統級別的線程(也稱爲平臺線程)相比,它的創建開銷更小、資源利用率更高,是 Java 併發編程領域的一項重要創新。 PS:虛擬線程正式發佈
概述 Github官方地址:GLM-4 網上已經有很多關於微調的文章,介紹各種方式下的使用,這裏不會贅述。我個人比較關心的是微調時的loss計算邏輯,這點在很多的文章都不會有相關的描述,因爲大多數人都是關心如何使用之類的應用層,而不是其具體
Like運算符很好用,特別是它所提供的其中*、?這兩種通配符,在Windows文件系統和各類項目中運用非常廣泛。 但Like運算符僅在VB中支持,在C#中,如何實現呢? 以下是關於LikeString的四種實現方式,其中第四種爲Regex正
前言 對於.NET開發人員來講,一個程序佔用內存過高,是極其糟糕,是一款不合格的程序軟件,.NET開發人員也不會去使用服務器垃圾收集器(ServerGarbageCollection),而是選用工作站垃圾收集器,而是對於一款低
可以說是一個toy program,chatgpt完成了一部分工作,我也完成了一部分工作,我倆合作的,我佔百分之80%,他百分之20%,哈哈沒他不行,源碼奉上。https://github.com/Jinwenxin/test-api-fr
using Org.BouncyCastle.Utilities.Encoders; using System; using System.Collections.Generic; using System.Linq; using Syst
https://www.gbtgames.com/thread-1198.htm 都是安裝包, 扔迅雷裏面就行. 都很乾淨沒廣告.
一:背景 1. 講故事 前些天有位朋友找到我,說他們的程序內存會偶發性暴漲,自己分析了下是非託管內存問題,讓我幫忙看下怎麼回事?哈哈,看到這個dump我還是非常有興趣的,居然還有這種遊戲幣自助機類型的程序,下次去大玩家看看他們出幣的機器後端
html <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="basic.css"> </head> <body> <div class="masked-element">
1、數據 2、全選日期(從8到22的所有日期) 3、爲全選日期新增規則 規則1(當前日期>=開始日期,當前日期<=結束日期) 公式裏面$符號去掉格式如下 格式化如下 點確定如下 規則2(超過當前日期)
官網:https://cloud.tencent.com/document/product/436/12269 安裝包,這裏用的python2.7 # pip install -U cos-python-sdk-v5 -i http
create procedure p() begin create table casbin_rule_copy2 select distinct * from casbin_rule; drop table casbi
Problem - 1255 (hdu.edu.cn) 題意 在二維平面座標軸上輸入n個矩形,問被這n個矩形覆蓋了兩次或兩次以上的區域的面積總和。 給的題意有點問題,實際輸入是矩形的左下和右上,另外樣例1應該輸出7.62. 思路 掃描線,這
在處理PDF文件時,我們可能會遇到這樣的情況:原始PDF文檔不符合我們的閱讀習慣,或者需要適配不同顯示設備等。這時,我們就需要及時調整PDF文檔中的頁面尺寸,以滿足不同應用場景的需求。 利用Python語言的高效性和靈活性,再結合Spire