Avatar of milesryoung
milesryoungFlag for Germany

asked on 

When using the type "Keys" for a class/custom component, how can I set the "Default" attribute?

I've created my own custom component for using with a barcode scanner. Two of my properties are "ScanPreamble" and "ScanPostamble" and I want the default values to be "F8" and "F9" respectively.

Unfortunately, when I create an instance of this component, both properties are set to "None". I've tried the following and none of this works:

<DefaultValue(GetType(Keys), "Keys.F8")> _

<DefaultValue(GetType(Keys), "F8")> _

<DefaultValue(119)> _

Much obliged to whoever helps me fix this.
Dim keyScanPreamble As Keys
    Dim keyScanPostamble As Keys
 
<Category("Details")> _
    <Description("Key used to start a scan - Preamble")> _
    <DefaultValue(GetType(Keys), "Keys.F8")> _
    Public Property ScanPreamble() As Keys
        Get
            Return keyScanPreamble
        End Get
        Set(ByVal value As Keys)
            keyScanPreamble = value
        End Set
    End Property
 
    <Category("Details")> _
    <Description("Key used to end a scan - Postamble")> _
    <DefaultValue(GetType(Keys), "Keys.F9")> _
    Public Property ScanPostAmble() As Keys
        Get
            Return keyScanPostamble
        End Get
        Set(ByVal value As Keys)
            keyScanPostamble = value
        End Set
    End Property

Open in new window

Visual Basic.NET

Avatar of undefined
Last Comment
milesryoung
ASKER CERTIFIED SOLUTION
Avatar of Joel Coehoorn
Joel Coehoorn
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of milesryoung
milesryoung
Flag of Germany image

ASKER

Thanks. That does solve the problem. I'd still like to see why the default attribute doesn't work the way it does with other types.
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo