Hey all i have the following code:
Dim validFileTypes As String() = {".bmp", ".gif", ".png", ".jpg", ".jpeg", ".tif"}
For x = 0 To NumberOfBoxes - 1
With myTxtData(x)
If Not Fields("customField" & z).Value.Equals(DBNull.Value) Then
If InStr(Fields("customField" & z).Value, "@") <> 0 Then
'Lower case the email address
.Text = StrConv(Fields("customField" & z).Value, VbStrConv.Lowercase)
ElseIf InStr(StrConv(Fields("customField" & z).Value, VbStrConv.Lowercase), ".jpg") <> 0 Then
'It contains an image!
Else
.Text = StrConv(Fields("customField" & z).Value, VbStrConv.ProperCase)
End If
etc etc.....
Instead of me checking this way:
ElseIf InStr(StrConv(Fields("customField" & z).Value, VbStrConv.Lowercase), ".jpg") <> 0
OR InStr(StrConv(Fields("customField" & z).Value, VbStrConv.Lowercase), ".png") <> 0
OR InStr(StrConv(Fields("customField" & z).Value, VbStrConv.Lowercase), ".gif") <> 0
...etc...
How can i use my defined validFileTypes to do the same but with less code?
You will need to possibly add a little code, but this should get you down the right path: