Private Sub btnOK_Click()
Const c_strPath As String = "G:\Data\"
Dim strName As String, strClient As String, strJob As String, _
strDesc As String
Dim booOKtoWriteFile As Boolean, intHandle As Integer
booOKtoWriteFile = True
strClient = tbxClient.Text
strJob = tbxJob.Text
strDesc = tbxDesc.Text
Range("aj5") = Now()
dnes = Range("aj5")
If cbxName.Text <> "" Then
strName = fnNameToInit(cbxName.Text)
Else
MsgBox "Sélectioner votre nom", vbExclamation
booOKtoWriteFile = False
End If
If strJob = "" Then
MsgBox "Le no. job ou soum. est requis", vbExclamation
booOKtoWriteFile = False
End If
If strClient = "" Then
MsgBox "Écrire le nom du client", vbExclamation
booOKtoWriteFile = False
End If
If strClient = "" Then
MsgBox "Écrire une description", vbExclamation
booOKtoWriteFile = False
End If
If Not Range("Sheet1!AI6:AI30000").Find(Me.tbxJob.Text) Is Nothing Then
MsgBox "ce texte est deja dans la base de donné", vbInformation, "Already exists"
booOKtoWriteFile = False
End If
End Sub
If booOKtoWriteFile Then
intHandle = FreeFile
Open c_strPath & "_________" & ".txt" For Output As #intHandle
Write #intHandle, dtmNew, strClient, strDesc, strXXXX, 0, 0, 0, 0, strName
Close #intHandle
Open c_strPath & "nojob.txt" For Append As #intHandle
Write #intHandle, strXXXX
Close #intHandle
tbxName = ""
tbxJob = ""
tbxClient = ""
tbxDesc = ""
End If
Range("BK1").Select
End Sub
Private Function fnNameToInit(strInput As String) As String
Dim strTemp As String, intPos As Integer
strTemp = Left(strInput, 1)
intPos = InStr(1, strInput, " ")
If intPos <> 0 _
And intPos < Len(strInput) Then
strTemp = strTemp & Mid(strTemp, intPos + 1, 1)
End If
'// Any exceptions, i.e. names that would result
'// in a duplicate value. For example my name
'// would yield the same value as Genevieve.
'// So override the default results.
If UCase(strInput) = "GREG TRUBY" Then
strTemp = "GT1"
ElseIf UCase(strInput) = "MARLON BRANDO" Then
strTemp = "MB1"
End If
fnNameToInit = strTemp
End Function