PDA

View Full Version : Help VBA search



TANDATNGUYEN
10-31-2019, 02:17 AM
Please help me to see if there are any errors in the form2 when I used the SEARCH button.

paulked
10-31-2019, 06:09 AM
I'm scared to open it for a few of reasons...

1. It's your first post
2. The question is ambiguous and
3. The flags are Vietnam and Alaska - if those two flags together mean something then I apologise for my ignorance, I'm Welsh!

SamT
10-31-2019, 11:12 AM
Chào

The first thing I looked at was VBAProper. I rewrote it to be a little shorter and possibly faster
Option Explicit

Function VBAProper(ByVal MyText As String) As String
Dim i As Long
Dim Arr As Variant

If Trim(MyText) = "" Then Exit Function

MyText = LCase(MyText)
Arr = Split(MyText)
For i = LBound(Arr) To UBound(Arr)
MyText = MyText & UCase(Left(Arr(i), 1)) & Mid(Arr(i), 2, Len(Arr(i)))
Do While i <> UBound(Arr): MyText = MyText & " ": Loop
Next i
VBAProper = MyText
End Function
You have VBAProper in two modules: Delete one copy

Then I noticed that all your UserForm Controls had Control.Type prefixes (txDAYKD or txtTENKH,) but, in your code, they were all without prefixes, (DAYKD or TENKH.)

With a little creative thinking, you can select all Control subs, then use CTRL+H to replace all "Sub " with "Sub txt", and rename control txDAYKD to txtDAYKD

If you place "Option Explicit" at the top of every code page, then use VBA Menu Debug >> Compile, you will find most errors in your code.


Chúc may mắn

Leith Ross
11-03-2019, 07:25 PM
@ paulked,

I was wondering about that same thing. What is even stranger is the times are the same. How is that possible?