为文本文件构建UI /输入表单 [英] Build a UI / input form for a text file
问题描述
我有一个文本文件,用作其他系统的输入它包含数据,如
city,date
new york ,17/02/2012
芝加哥,2011年3月17日
我需要在此文本文件的顶部构建一个前端验证任何用户输入。基本上需要确保日期输入正确等。
我需要构建一个表单/网页,任何将从用户那里获取输入并具有上述文本文件的内容作为数据库。
你能告诉我哪种方法最好吗?
我尝试了什么:
angularjs html5 excel-vba csv javascript
i have a text file which is used as a input for other system It contains data like
city,date
new york,17/02/2012
chicago,17/03/2011
I need to build a frontend on top of this text file to validate any user input . Basically need to make sure date is entered correct etc .
I need to build a form/web page anything which will take input from user and have a text file as above as a database .
can you please tell me which is the best way to do this ?
What I have tried:
angularjs html5 excel-vba csv javascript
推荐答案
如果excel vba是可接受的解决方案:
If excel vba is an acceptable solution:
Option Explicit
Sub ValidateMyFile()
Dim FileName As String
Dim iFileNo As Integer
Dim sCity As String
Dim sDate As String
Dim lLineCounter As Long
Dim lErrorCount As Long
Dim iLinesToSkip As Integer ' to skip any header lines
iLinesToSkip = 1
On Error GoTo ErrorHandler
'this next line assumes that you have a named range in your workbook
'that contains the full path of the file to process
'FileName = Range("FileNameToProcess")
'or you could prompt the user for a file path\name:
'FileName = InputBox("Enter file path and name: ", "File to Validate")
'for testing I created a test file and hard coded the path\name
FileName = "C:\temp\TestFile.txt"
'check to see if the file exists
If Dir(FileName) = "" Then
MsgBox "File not found... exiting", vbCritical, "File Validatorizer"
Exit Sub
End If
iFileNo = FreeFile
Open FileName For Input As iFileNo
lLineCounter = 0
For lLineCounter = 1 To iLinesToSkip
Input #iFileNo, sCity, sDate
Next
Do While Not EOF(iFileNo)
lLineCounter = lLineCounter + 1
Input #iFileNo, sCity, sDate
If Not IsDate(sDate) Then
MsgBox "Bad date at line: " & lLineCounter & " for city: " & sCity & " Bad Date: " & sDate
lErrorCount = lErrorCount + 1
End If
Loop
Close
MsgBox "Done!" & vbCrLf & vbCrLf & "Processed: " & lLineCounter & " lines" & vbCrLf & "Found: " & lErrorCount & " errors", vbExclamation
Exit Sub
ErrorHandler:
MsgBox Err.Description & vbCrLf & vbCrLf & "Exiting ..."
End Sub
这篇关于为文本文件构建UI /输入表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!