'【股票类别查询函数】 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|深市创业板", "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|沪市权证", "031|深QZ|深市权证", "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》