How to: Determine the String Associated with an Enumeration Value (Visual Basic)
The GetValues and GetNames methods allow you to determine the strings and values associated with enumeration members.
To determine the string associated with an enumeration
Use the GetNames method to retrieve the strings associated with the enumeration members. This example declares an enumeration,
flavorEnum
, then uses the GetNames method to display the strings associated with each member.Public Enum flavorEnum salty sweet sour bitter End Enum Private Sub TestMethod() MsgBox("The strings in the flavorEnum are:") Dim i As String For Each i In [Enum].GetNames(GetType(flavorEnum)) MsgBox(i) Next End Sub
See also
Colaborați cu noi pe GitHub
Sursa pentru acest conținut poate fi găsită pe GitHub, unde puteți, de asemenea, să creați și să consultați probleme și solicitări de tragere. Pentru mai multe informații, consultați ghidul nostru pentru colaboratori.
Feedback
https://aka.ms/ContentUserFeedback.
În curând: Pe parcursul anului 2024, vom elimina treptat Probleme legate de GitHub ca mecanism de feedback pentru conținut și îl vom înlocui cu un nou sistem de feedback. Pentru mai multe informații, consultați:Trimiteți și vizualizați feedback pentru