Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

RE: [V8i VBA] How to determine a form control's object name?

$
0
0

[quote user="Barry Lothian"]The problem is I have hard-coded the textbox object name[/quote]

As Jan writes, you don't need to do that.  You know which control invoked your subroutine: TB_CustomRed, TB_CustomBlue or TB_CustomGreen.  Write your subroutine as PrivateSub ValidateRGB(ByVal value As String) and pass it the value of whichever text box.

VBA Logical Expression Evaluation

[quote user="Barry Lothian"]IfNotIsNumeric(.Value) And.Value <> vbNullString Then[/quote]

Unlike most other computer languages, VBA evaluates all expressions in a logical statement.  In your case, it's possible to have an empty string that may cause IsNumeric(.Value) to throw an error.  The following avoids that error...

If .Value <> vbNullString Then
  If IsNumeric(.Value) Then
    Dim number As Double
    number = Dbl(.Value)
  Else
    '  Not numeric
  End If
Else
  '  Empty string
End If

Viewing all articles
Browse latest Browse all 7260


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>