[RESOLVED] Need help on how to create a look up form.
Hi All,
Lets say i have a folder which contains some file.{ eg: QHDE.PMB , QDHE.PMD }
inside these .PMB files, contains some code/data.
i have copied the code/data into .INI file
How do i create a form to do look up table ?
Eg:when i enter "PMB" in a label/text it should extract data from the .INI file and use that as reference for some condition.
INI file is not a good choice and would be much harder to do what you seem to need. Database is simple and something that if you do not already know now is a good time to start.
I would not waste my time trying to make such a thing work with an ini file.
INI file is not a good choice and would be much harder to do what you seem to need. Database is simple and something that if you do not already know now is a good time to start.
I would not waste my time trying to make such a thing work with an ini file.
i have gone through the forum but i need some time to study/understand it.
Im running out of time as i need to complete this project as soon as possible n do presentation . thats y i opted to go with .INI first.
once im done with the presentation, i can study the ADO and change it later
Any other simple method ? i have attached the pic . thanks
So show us the code you have written, You say you are using INI files but you have not shown a sample of the INI structure nor any code and a screen shot doesn't do much to help.
I still think you should be working at using a database. It will not be easy to do this with an INI file and whatever you learn while trying to make this work will not be something that will be likely to be used again, whereas using a proper database would be very useful to you here and in the future.
So show us the code you have written, You say you are using INI files but you have not shown a sample of the INI structure nor any code and a screen shot doesn't do much to help.
I still think you should be working at using a database. It will not be easy to do this with an INI file and whatever you learn while trying to make this work will not be something that will be likely to be used again, whereas using a proper database would be very useful to you here and in the future.
Hi,
i will try to study database. Meanwhile below is the code:
i manage to create the combo list but how do link it to call INI setting ?
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function GetPrivateProfileInt Lib "kernel32" _
Alias "GetPrivateProfileIntA" _
(ByVal sSectionName As String, _
ByVal sKeyName As String, _
ByVal lDefault As Long, _
ByVal sFileName As String) As Long
Private Declare Function GetPrivateProfileString Lib "kernel32" _
Alias "GetPrivateProfileStringA" _
(ByVal sSectionName As String, _
ByVal sKeyName As String, _
ByVal sDefault As String, _
ByVal sReturnedString As String, _
ByVal lSize As Long, _
ByVal sFileName As String) As Long
'Scanner data settings
Private nTotalLengthReceive As Integer
Private nDataLength As Integer
'Comm port settings
Private sSettings As String 'Settings: Baurate,parity,data bit,stop bit; example: Settings=9600,n,8,1
Private nCommport As Integer
Private nHandshaking As Integer 'Handshaking: 0:None, 1:XOnXOff, 2:RTS, 3:RTSXOnXOff
Private nInputMode As Integer 'InputMode: 0:Text, 1:Binary
Private nInputLen As Integer
Private nRThreshold As Integer
Private nSThreshold As Integer
Private bDTREnable As Boolean
Private bEOREnable As Boolean
Private bRTSEnable As Boolean
Private iTimeOut As Integer
Private nAutoSaveData As Integer 'Auto save data after how many scan
Do
strInput = strInput & MSComm1.Input
Text5.Text = strInput
'DoEvents
I = I + 1
'strEnd = Right(strInput, 2) 'Incase want to check Terminal Characters
Text3.Text = I
Loop Until (Len(strInput) >= nTotalLengthReceive) Or (I > iTimeOut)
If I >= iTimeOut Then
MSComm1.PortOpen = False
Text1.Text = strInput
Label7.BackColor = vbRed
LabelPF = "FAIL VERICODE"
LabelPF.BackColor = vbRed
ShapeResult.BackColor = vbRed
TextErrorMessage.Text = "FAIL VERICODE"
' List1.AddItem (strNow & " , " & Text1.Text & " FAIL"), 0 'Add data in List Box
' kCounter = kCounter + 1
' Label8.Caption = kCounter
DoEvents
nRetry = nRetry + 1
Text4.Text = nRetry
Else
If (List1.ListCount >= nAutoSaveData) Then Call Command2_Click 'Auto save data after how many scan
Text1.Text = Left(strInput, nDataLength)
Label7.Caption = Left(strInput, nDataLength)
If Check1.Value = 1 Then
Clipboard.Clear
Clipboard.SetText (Label7.Caption)
End If
strNow = Format(Now, "YYYY-MM-DD")
strNow = strNow & " " & Format(Now, "HH:MM:SS") 'Get current Date and Time
' List1.AddItem (strNow & " , " & Text1.Text & " PASS"), 0 'Add data in List Box
nRetry = 0
Text4.Text = nRetry
End If
Text2.Text = Len(strInput)
DoEvents
Sleep (200)
If (MSComm1.PortOpen = False) Then
MSComm1.PortOpen = True
Sleep (200)
End If
End Sub
Private Sub LoadSettings()
Dim sString As String
Dim lSize As Long
Dim iReturn As Integer
Dim sNull As String
Dim sFile As String
Dim strDirExists As String
Private Sub WinsockHSA_DataArrival(ByVal bytesTotal As Long)
' TCP Socket Data Receive Event
Dim strTemp As String
strTemp = ""
'Start to get data
WinsockHSA.GetData strTemp, vbString
'Amend Data
strTCPHSADataRecv = strTCPHSADataRecv & strTemp
'Check if all data has been received
If Len(strTCPHSADataRecv) > 12 Then
If Len(strTCPHSADataRecv) = Mid(strTCPHSADataRecv, 7, 5) Then
blnTCPHSADataFinish = True
End If
End If
End Sub
Private Sub WinsockHSA_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
' TCP Socket Error Event
blnWinSockHSAError = True
If WinsockHSA.State <> sckClosed Then
WinsockHSA.Close
End If
DoEvents
End Sub
//---------------------------------------------------------------------------------------------
// I need to add in case statement based on INI at this section
Private Sub CheckHSAData(ByVal strSN As String)
Dim strDataBack As String
Dim fresult As String
Dim Tem As String
TextErrorMessage.Text = "Checking HSA Data From Venus-Q server,Please wait for a while"
If strDataBack = "21" Or strDataBack = "10" Or strDataBack = "" Then
CurrentDevice.HSAData = "NG"
CurrentDevice.ResultHSADataPass = False
Me.ShapeResult.BackColor = vbRed
Me.LabelPF = "HSA DATA FAIL"
TextErrorMessage.Text = "HSA Data Fail Or Fail to retrieve HSA Data."
'Fail Vericode
Call FinalResult
End If
If strDataBack = "00" Then
CurrentDevice.ResultHSADataPass = True
CurrentDevice.HSAData = "OK"
Me.ShapeResult.BackColor = vbGreen
Me.LabelPF = "HSA DATA PASS"
TextErrorMessage.Text = "HSA DATA PASS"
End If
End If
End Sub
//----------------------------------------------------------------------------------------------
Public Sub FinalResult()
Dim I As Long
Dim strInput As String
Dim strEnd As String
Dim strNow As String
Dim strDataBack As String
If Label7.BackColor = vbGreen = True And Me.LabelPF = "HSA DATA PASS" Then
Me.ShapeResult.BackColor = vbGreen
Me.LabelPF = " PASS "
lCounter = lCounter + 1
Label5.Caption = lCounter
strNow = Format(Now, "YYYY-MM-DD")
strNow = strNow & " " & Format(Now, "HH:MM:SS") 'Get current Date and Time
List1.AddItem (strNow & " , " & Text1.Text & " PASS" & "," & strDataBack), 0 'Add data in List Box
Else
Me.ShapeResult.BackColor = vbRed
Me.LabelPF = " FAIL "
kCounter = kCounter + 1
Label8.Caption = kCounter
strNow = Format(Now, "YYYY-MM-DD")
strNow = strNow & " " & Format(Now, "HH:MM:SS") 'Get current Date and Time
List1.AddItem (strNow & " , " & Text1.Text & ", " & " FAIL " & "," & strDataBack), 0 'Add data in List Box
I didn't mean to post your whole project code, just that which is related to reading the ini file along with a sample of the ini file structure you are trying to use.
btw in the length of time since you first posted till now you could have probably figure dout how to do it with a database and even if not if you wrote some code for it and ran into issues it would be a lot easier to get help as most people would not use an ini file for such a thing nor would they really want to spend the time to try and make an ini work for something like this.
You could haul groceries back from the store using a tricycle and a wagon but wouldn't it be better to use a car?