Visualizzazione dei risultati da 1 a 8 su 8
  1. #1
    Utente bannato
    Registrato dal
    Mar 2002
    Messaggi
    80

    Tasti funzione in Visual Basic

    Come posso fare per inserire in un progetto di vb dei tasti funzione (se si chiamano così).
    Mi spiego meglio: io vorrei avere la possibilità di fare in modo che premendo ad esempio il tasto F6 si aprisse un determinato form.

    Grazie mille!


  2. #2
    Utente di HTML.it L'avatar di Mabi
    Registrato dal
    May 2002
    Messaggi
    1,245
    Ti basta impostare su True la KeyPreview del form "principale" e intercettare il codice del tasto premuto nella KeyDown del form.
    codice:
    If KeyCode = 117 Then
      'Apri il form
    End If
    Ciao !

  3. #3
    Utente bannato
    Registrato dal
    Mar 2002
    Messaggi
    80
    Grazie!

    Sei stato gentilissimo


  4. #4
    Utente bannato
    Registrato dal
    Mar 2002
    Messaggi
    80
    dove posso trovare i numeri corrispondenti ai vari tasti?
    nn riesco a farlo andare

  5. #5
    guarda cosa ho trovato nei miei vecchi appunti
    codice:
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = 112 Then
            Label1.Caption = Label1.Caption & " F1"
        End If
        If KeyCode = 113 Then
            Label1.Caption = Label1.Caption & " F2"
        End If
        If KeyCode = 114 Then
            Label1.Caption = Label1.Caption & " F3"
        End If
        If KeyCode = 115 Then
            Label1.Caption = Label1.Caption & " F4"
        End If
        If KeyCode = 116 Then
            Label1.Caption = Label1.Caption & " F5"
        End If
        If KeyCode = 117 Then
            Label1.Caption = Label1.Caption & " F6"
        End If
        If KeyCode = 118 Then
            Label1.Caption = Label1.Caption & " F7"
        End If
            If KeyCode = 119 Then
            Label1.Caption = Label1.Caption & " F8"
        End If
        If KeyCode = 120 Then
            Label1.Caption = Label1.Caption & " F9"
        End If
        If KeyCode = 121 Then
            Label1.Caption = Label1.Caption & " F10"
        End If
    End Sub

  6. #6
    Utente bannato
    Registrato dal
    Mar 2002
    Messaggi
    80
    Originariamente inviato da Johnny_Depp
    guarda cosa ho trovato nei miei vecchi appunti
    codice:
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = 112 Then
            Label1.Caption = Label1.Caption & " F1"
        End If
        If KeyCode = 113 Then
            Label1.Caption = Label1.Caption & " F2"
        End If
        If KeyCode = 114 Then
            Label1.Caption = Label1.Caption & " F3"
        End If
        If KeyCode = 115 Then
            Label1.Caption = Label1.Caption & " F4"
        End If
        If KeyCode = 116 Then
            Label1.Caption = Label1.Caption & " F5"
        End If
        If KeyCode = 117 Then
            Label1.Caption = Label1.Caption & " F6"
        End If
        If KeyCode = 118 Then
            Label1.Caption = Label1.Caption & " F7"
        End If
            If KeyCode = 119 Then
            Label1.Caption = Label1.Caption & " F8"
        End If
        If KeyCode = 120 Then
            Label1.Caption = Label1.Caption & " F9"
        End If
        If KeyCode = 121 Then
            Label1.Caption = Label1.Caption & " F10"
        End If
    End Sub
    Grazie mille!

  7. #7
    Utente di HTML.it
    Registrato dal
    Oct 2002
    Messaggi
    271
    Penso che invece di fare quella seri infinita di IF sia meglio fare una SELECT CASE KeyCode!!

    Ma poi, non sarebbe + semplice creare un menu (magari invisibile se non lo vuoi vedere) nell' MDI form e associare ad ogni voce l'opzione ShortCut con il tasto desiderato (F1, F2, F3, ...)?

  8. #8
    Utente di HTML.it L'avatar di yyzyyz
    Registrato dal
    Oct 2001
    Messaggi
    1,653

    thx

    grazie, proprio quello ke mi serviva.
    :mavieni:

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.