Log in to reply
 

Help Requested. Stuck on C# Code to VB.Net



  • I've been having a relatively easy time adapting C# Code to VB.Net but TBH I'm completely stuck on this one and I have a feeling it's something simple - but beyond my beginner's knowledge.

    I'd like to create a simple menu for myself to spawn peds, vehicles, etc. Will still use Menyoo when sandboxing but would like something simpler as well.

    I downloaded the Empty Native UI template from the Mods and everything looked straight forward to convert to VB.Net except for this. I know C# has its own Tick, KeyDown, KeyUp and so does VB, but why are these included in another function? First time I encounter this and I don't understand what it means in C# let alone convert it to VB.Net. I'm stuck!

    public MenuExample()
    {
    _menuPool = new MenuPool();
    var mainMenu = new UIMenu("Menu", "");
    _menuPool.Add(mainMenu);

        Menu1(mainMenu);
        Menu2(mainMenu);
    
        _menuPool.RefreshIndex();
        Tick += (o, e) => _menuPool.ProcessMenus();
        KeyDown += (o, e) =>
        {
            if (e.KeyCode == Keys.Z && !_menuPool.IsAnyMenuOpen())
                mainMenu.Visible = !mainMenu.Visible;
        };
    

    P.S. How do i insert code properly in a post?



  • Ok, I fixed it although I'm still confused as to why the author did it that way.

    My fix, in VB.Net was take the functions out and put them where I would have expected them to be.

    Private Sub OnkeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
    If e.KeyCode = Keys.Z AndAlso Not _menuPool.IsAnyMenuOpen() Then MainMenu.Visible = Not MainMenu.Visible
    End Sub

    Private Sub OnTick(sender As Object, ByVal e As EventArgs) Handles Me.Tick
    _menuPool.ProcessMenus()
    End Sub

Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.