dcsimg
Results 1 to 2 of 2

Thread: Cast To UDT? CType Equivalent

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2015
    Posts
    38

    Cast To UDT? CType Equivalent

    Is there a way to cast a variable as a UDT without creating a variable?

    This is pretty stupid:
    Code:
    Do While M.GUIQueue.Count > 0
        Request = M.GUIQueue.Item(1)
        Select Case TypeName(Request)
            Case "Command"
                Dim Command As Command
                Command = Request
                Call LoadControl(Command)
            Case "Player"
                Dim Player As Player
                Player = Request
                Call LoadPlayer(Player)
            Case "Game"
                Dim Game As Game
                Game = Request
                Call SetScore(Game)
                
        End Select
        M.GUIQueue.Remove 1
    Loop
    I would like to just be able to LoadPlayer(CType(Request, Player))...

    I don't want to variant the parameter either, because then you lose the nice autocomplete.

    Thanks,
    PsuFan

  2. #2
    Hyperactive Member
    Join Date
    Feb 2019
    Posts
    382

    Re: Cast To UDT? CType Equivalent

    When faced with the same situation, I use Enum. It's faster than String comparison, and I get Intellisense.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width