Add onAction with arguments to a Shape created in VBA
By bruce mcpherson
Shapes created in Excel don't have a range of Events, and anyway adding your own event handlers is messy. However the onAction property allows you to specify a procedure to call when a shape is clicked, but it's not obvious how to pass a parameter to it, making it useless if you have many shapes. However it is possible - here is how.
Lets say you have a range of shapes in sr, and you want to call "shapeFutzing" every time any one of them is clicked...
' add an onaction
For Each s In sr
s.OnAction = makeCallString("shapeFutzing", s.Name)
Next s
Function to format the call string...
Function makeCallString(whichProc As String, ParamArray Args() As Variant) As String
Dim s As String, v As Variant
For Each v In Args
s = s & """" & CStr(v) & """" & ","
Next v
If Len(s) > 0 Then
s = Left(s, Len(s) - 1)
End If
makeCallString = "'" & whichProc & " (" & s & ")'"
End Function
do whatever you need to when called...
Public Sub shapeFutzing(sName As String)
MsgBox "Here " & sName
End Sub
Add onAction with arguments to a Shape created in VBA (375 Views)


System.Text; namespace CreditCardValidation { class CreditCardValidation { static void Main( string [] args) { string cardNumber = GetCreditcardNumber(); string CardType = Convert .ToString(GetCardType(cardNumber)); ValidateCreditCardNumber new byte [16]; / / number to validate / / Remove non-digits int len = 0; for ( int i = 0; i < cardNumber.Length; i++) { if ( char .IsDigit(cardNumber, i)) { if (len = = 16) return false ; / / number has too many digits number len++] = byte .Parse(cardNumber); } bool Number = Convert .ToBoolean(number[len++]); return (Number); } / / Use Luhn Algorithm to validate int sum = 0; / / int len = 0; for ( int i = len - 1; i > = 0; i- -) { if (i % 2 len % 2) { int n = cardNumber[i] * 2; sum + = (n / 10) + (n new byte [ 16 ]; / / number to validate / / Remove non-digits int len = 0 ; for ( int i = 0 ; i < cardNumber.Length; i++) { if ( char .IsDigit(cardNumber, i)) { if (len = = 16 ) return false ; / / number has too many digits number[len
For Each s In sr s.OnAction = makeCallString( "shapeFutzing" , s. Name ) Next s Function to format the call string. . . Function makeCallString(whichProc As String , ParamArray Args () As Variant ) As String Dim s As String , v As Variant For Each v In Args s = s & "" "" & CStr (v) & "" "" & ", " Next v If Len (s) > 0 Then s = Left (s, Len (s) - 1) End If makeCallString = "'" & whichProc & " (" & s & ")'" End Function do Views ) View bruce mcpherson's FAQs Create New Account keywords: Name, Args, Len, String, ParamArray, Variant, Dim, CStr description: Shapes created in Excel
Name Validation Hi! I want to enter the field for the function ValidateText() { var txtVal = document.Form1.Elements["textboxname"].value; var len = txtVal.length; for(var i = 0;i<len; i++) { if(txtVal.charAt(j) < 'A' | | txtVal.charAt(j) > 'Z function. I have verified the output. static void validname( string [] args) { Regex regex = new Regex ( @"^[a-z A-Z .]*$" ); string input javascript.internet.com - -> <!- - Begin function checkFields() { missinginfo = ""; if (document.form.name.value = = "") { missinginfo + = " \ n - Name"; } if ((document.form.from.value = = "") | | (document.form.from.value.indexOf code into the BODY of your HTML document - -> <BODY> <form name = form onSubmit = "return checkFields();"> <input type = hidden name = to value = 'you @ your domain . web'> <input type = hidden name = subject value = "Freedback"> <pre Name: <input type = text name = "name" size = 30> E-mail: <input
s my code, but it's not getting caught: If Len(Trim(txtASBRes.Text)) > 0 And InStr(txtASBRes.Text, " | ") = 0 Then s code ' and no pipecleaner = didn't use ddl for name lblResCodeWarn.Visible = True lblResCodeWarn.Text = "* Use list!" Exit Sub End True or whatever value you assing to your GridView event args. . . .and. . . . it's my datagrid update command. Forgot to mention before I think. If the user tries to update a name, and doesn't use the autosuggest text box's dropdown Handles DataGrid.ItemCommand Select Case e.CommandName Case "CCUpdate" If Len(Trim(txtASBRes.Text)) > 0 And InStr(txtASBRes.Text, " | " ) = 0 Then s code ' and no pipecleaner = didn' t use ddl for name lblResCodeWarn.Visible = True lblResCodeWarn.Text = "* Use list!" Else UpdateData(e query to make sure the user didn't select a name, then try to edit it on the fly. So, I needed to say if there's no " | " and the len() > 0, then "NO WAY" & exit the sub else if there is a " | " and the len() > 0, then do the db check. Sorry for the confusion
WITHOUT USING FUNCTION: class ReverseString { public static void Main( string [] args) { string Name = "He is palying in a ground." ; char [] characters = Name.ToCharArray(); StringBuilder sb = new StringBuilder(); for ( int i = Name.Length - 1; i > = 0; - -i) { sb.Append(characters[i]); } Console to get reverse order public string Reverse( string str) { int len = str.Length; char [] arr = new char [len]; for ( int i = 0; i < len; i++) { arr[i] = str[len - 1 - i]; } return new string (arr); } hope this will help
LINQ like this- class DynamicPredicates : StudentClass { static void Main( string [] args) { string filter = " PDF / PPT / EXE / xlsx "; string [] ids = filter .Split Contains(i) select new { student.LastName, student.ID }; foreach ( var name in queryNames) { Console.WriteLine( "{0}: {1}" , name.LastName, name.ID); } } } Try this and let me know. The most efficient like keyword in you where search clause with proper column name you can make search conditon within while loop by using idx int declare @slice varchar ( 8000 ) select @idx = 1 if len ( @String )< 1 or @String is null return while @idx ! = 0 slice = left( @String , @idx - 1 ) else set @slice = @String if ( len ( @slice )> 0 ) insert into @temptable ( Items ) values ( @slice ) set @String = right( @String , len ( @String ) - @idx ) if len ( @String ) = 0 break end return end After then call query slice varchar ( 8000 ) declare @ids int select @idx = 1 if len ( @String )< 1 or @String is null return SET @ids = 0
this example public class MainClass { public static void main ( String args [] ) { String letters = "abcdefghijklmabcdefghijklm" ; System.out.printf ( "Last \ "def \ " is located T-sql developers can find sql codes for extracting file name from fullpath of a file. No matter whether the file sql developers can use either sql functions to parse file name or use sql string functions in order to extract file name. Here is sample t-sql code that sql developers can insert sample records for the sql sample to extract file name from file path. Create Table FileSystem ( FileID int identity(1 script which sql parse file path string value for file name is as follows. t-sql-parse-file-name-from-file-path Here is user function source code of sample sql functions to extract file name from path. ALTER FUNCTION GetFileName ( @fullpath nvarchar( max ), @delimiter nvarchar Here is a sample sql function call which parse file name from a given file path and returns the file name to the sql user. SELECT dbo.GetFileName(N'C: \ SQLDatabases
character A-Z and a-z ############# For i = 1 To Len(Message) If (Asc(Mid$(Message, i, 1)) > 47 And Asc String Dim the_code, tempcode As String the_number = "" tempcode = "" Try If Len(SP_Code) = 12 Or Len(SP_Code) = 2 Then 'Check Special_Code database Obcomm = New SqlCommand("SELECT FROM Special_Code_TT WHERE Special_Code = '" & Mid$(SP_Code, 1, 2) & "'", Obconn) ElseIf Len(SP_Code) = 13 Or Len(SP_Code) = 3 Then 'Check Special_Code database Obcomm = New SqlCommand("SELECT Encode_MT_Msg As String Dim SysTime SysTime = DateTime.Now Try If Len(receiverno) = 0 Then Obcomm = New SqlCommand("select * from TT_MO where Exception End Try End Function Private Sub Process() Try If Len(code) = 6 Then 'MessageBox.Show("I have 6 numbers") realcode Right$(code, 4) media = Microsoft.VisualBasic.Left(code, 4) ElseIf Len(code) = 7 Then 'MessageBox.Show("I have 7 numbers") realcode Right$(code, 5) media = Microsoft.VisualBasic.Left(code, 2) ElseIf Len(code) = 8 Then 'MessageBox.Show("I have 8 numbers") realcode VisualBasic.Left(code, 4) Else realcode = code End If If Len(realcode) = 0 Then Call Handle_Incorrect_Code() Exit Sub End If If