'【股票類別查詢函數(shù)】 Public Function LBCX(ByVal cGpLx As String, Optional ByVal nL As Integer = 1) Dim cGpInt As String = Nothing Dim cGpOut As String = Nothing Dim i, nIn1, nIn2, nGp As Integer On Error Resume Next Dim aGpArr As Array = {"300|CYB|深市創(chuàng)業(yè)板", "600|滬A|滬市A股", "601|滬A|滬市A股", "603|滬A|滬市A股", "900|滬B|滬市B股", "000|深A|深市A股", "200|深B|深市B股", "002|ZXB|深市中小板", "700|滬PG|滬市配股", "080|深PG|深市配股", "580|滬QZ|滬市權(quán)證", "031|深QZ|深市權(quán)證", "730|滬SG|滬市新股", "430|LSB|老三板", "830|XSB|新三板"} cGpInt = IIf(Left(Trim(cGpLx), 2) = "43" Or Left(Trim(cGpLx), 2) = "83", Left(Trim(cGpLx), 2), Left(Trim(cGpLx), 3)) nGp = UBound(aGpArr) If nL = 0 Then For i = 0 To nGp '輸出股票類別簡碼 If InStr(aGpArr(i), cGpInt) > 0 Then nIn1 = InStr(aGpArr(i), "|") nIn2 = InStrRev(aGpArr(i), "|") cGpOut = Mid(aGpArr(i), nIn1 + 1, nIn2 - nIn1 - 1) Exit For End If Next ElseIf nL = 1 Then '輸出股票類別名稱 For i = 0 To nGp If InStr(aGpArr(i), cGpInt) > 0 Then nIn1 = InStr(aGpArr(i), "|") nIn2 = InStrRev(aGpArr(i), "|") cGpOut = Mid(aGpArr(i), nIn2 + 1) Exit For End If Next ElseIf nL = 2 Then '輸出滬市或深市的公司簡碼 For i = 0 To nGp If InStr(aGpArr(i), cGpInt) > 0 Then If InStr(aGpArr(i), "滬市") > 0 Then cGpOut = "sh" ElseIf InStr(aGpArr(i), "深市") > 0 Then cGpOut = "sz" Else cGpOut = "" End If Exit For End If Next End If Return cGpOut End Function |
|
來自: *藍星* > 《 VB 2015》