current state personal macrobook
This commit is contained in:
parent
7d0b38e46a
commit
95cc855722
@ -1876,6 +1876,64 @@ errh:
|
|||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Function FILEp_GetCSV(filepath As String) As String()
|
||||||
|
|
||||||
|
Dim fileNo As Integer
|
||||||
|
Dim fileContent As String
|
||||||
|
Dim fileLines() As String
|
||||||
|
Dim dataArray() As String
|
||||||
|
Dim splitArray() As String
|
||||||
|
Dim rowCount As Long, colCount As Long
|
||||||
|
Dim i As Long, j As Long
|
||||||
|
Dim final() As String
|
||||||
|
|
||||||
|
' Get an available file number
|
||||||
|
fileNo = FreeFile
|
||||||
|
|
||||||
|
' Open the file with the available file number
|
||||||
|
Open filepath For Input As fileNo
|
||||||
|
|
||||||
|
' Read the entire file content into a single string
|
||||||
|
fileContent = Input(LOF(fileNo), fileNo)
|
||||||
|
|
||||||
|
' Close the file
|
||||||
|
Close fileNo
|
||||||
|
|
||||||
|
' Split the file content into lines
|
||||||
|
fileLines = Split(fileContent, vbCrLf)
|
||||||
|
|
||||||
|
' Get the number of rows (lines)
|
||||||
|
rowCount = UBound(fileLines) - LBound(fileLines)
|
||||||
|
|
||||||
|
' Check if there are any lines in the file
|
||||||
|
If rowCount > 0 Then
|
||||||
|
' Split the first line into columns (using comma as a delimiter)
|
||||||
|
dataArray = Split(fileLines(0), ",")
|
||||||
|
|
||||||
|
' Get the number of columns
|
||||||
|
colCount = UBound(dataArray) - LBound(dataArray)
|
||||||
|
|
||||||
|
' Redimension the dataArray to the appropriate size
|
||||||
|
ReDim dataArray(0 To rowCount, 0 To colCount)
|
||||||
|
|
||||||
|
' Loop through the lines and columns to populate the dataArray
|
||||||
|
For i = 0 To rowCount
|
||||||
|
' Split the current line into columns
|
||||||
|
splitArray = Split(fileLines(i), ",")
|
||||||
|
|
||||||
|
' Loop through the columns
|
||||||
|
For j = 0 To colCount
|
||||||
|
' Assign the values to the dataArray
|
||||||
|
dataArray(i, j) = splitArray(j)
|
||||||
|
Next j
|
||||||
|
Next i
|
||||||
|
FILEp_GetCSV = dataArray
|
||||||
|
Else
|
||||||
|
MsgBox "The file is empty or not available."
|
||||||
|
End If
|
||||||
|
|
||||||
|
End Function
|
||||||
|
|
||||||
Public Function ADOp_Exec(ByRef con As Integer, ByVal sql As String, Optional ApproxSixe As Long, Optional InclHeaders As Boolean, Optional ByVal value As ADOinterface, Optional ConnectTo As String, Optional IntgrtdSec As Boolean, Optional UserName As String, Optional Password As String, Optional textconfigs As String) As Boolean
|
Public Function ADOp_Exec(ByRef con As Integer, ByVal sql As String, Optional ApproxSixe As Long, Optional InclHeaders As Boolean, Optional ByVal value As ADOinterface, Optional ConnectTo As String, Optional IntgrtdSec As Boolean, Optional UserName As String, Optional Password As String, Optional textconfigs As String) As Boolean
|
||||||
|
|
||||||
On Error GoTo errflag
|
On Error GoTo errflag
|
||||||
@ -2193,7 +2251,7 @@ Function json_concat(list As Range) As String
|
|||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function ADOp_BuildInsertSQL(ByRef tbl() As String, target As String, trim As Boolean, start As Long, ending As Long, ParamArray ftype()) As String
|
Public Function ADOp_BuildInsertSQL(ByRef tbl() As String, Target As String, trim As Boolean, start As Long, ending As Long, ParamArray ftype()) As String
|
||||||
|
|
||||||
|
|
||||||
Dim i As Long
|
Dim i As Long
|
||||||
@ -2202,7 +2260,7 @@ Public Function ADOp_BuildInsertSQL(ByRef tbl() As String, target As String, tri
|
|||||||
Dim sql As String
|
Dim sql As String
|
||||||
Dim rec As String
|
Dim rec As String
|
||||||
|
|
||||||
sql = "INSERT INTO " & target & " VALUES " & vbCrLf
|
sql = "INSERT INTO " & Target & " VALUES " & vbCrLf
|
||||||
For i = start To ending
|
For i = start To ending
|
||||||
rec = ""
|
rec = ""
|
||||||
If i <> start Then sql = sql & "," & vbCrLf
|
If i <> start Then sql = sql & "," & vbCrLf
|
||||||
@ -3023,6 +3081,8 @@ Function TBLp_VarToString(ByRef t() As Variant) As String()
|
|||||||
Dim j As Long
|
Dim j As Long
|
||||||
Dim x() As String
|
Dim x() As String
|
||||||
|
|
||||||
|
On Error GoTo errh
|
||||||
|
|
||||||
If LBound(t, 1) = 1 Then
|
If LBound(t, 1) = 1 Then
|
||||||
End If
|
End If
|
||||||
|
|
||||||
@ -3036,6 +3096,11 @@ Function TBLp_VarToString(ByRef t() As Variant) As String()
|
|||||||
|
|
||||||
TBLp_VarToString = x
|
TBLp_VarToString = x
|
||||||
|
|
||||||
|
errh:
|
||||||
|
If Err.Number <> 0 Then
|
||||||
|
MsgBox ("error on row: " & i)
|
||||||
|
End If
|
||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Function TBLp_StringToVar(ByRef t() As String) As Variant()
|
Function TBLp_StringToVar(ByRef t() As String) As Variant()
|
||||||
|
Loading…
Reference in New Issue
Block a user