Article View: free.it.visual-basic
Article #3915R: Lettere e Numeri
From: Max
Date: Sun, 10 Feb 2002 22:53
Date: Sun, 10 Feb 2002 22:53
69 lines
2897 bytes
2897 bytes
Ciao! Se ti interessa ci sono due simpatiche api che permettono di inserire solo numeri (senza decimali, purtoppo). Per conoscenza le scrivo qui. Private Const GWL_STYLE = (-16) Private Const ES_NUMBER = &H2000 Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _ (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _ (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Poi fai una subroutine tipo questa: Public Sub LeggiNumeri(ctrl As TextBox) Dim dwStyle As Long Dim lResult As Long dwStyle = GetWindowLong(ctrl.hwnd, GWL_STYLE) lResult = SetWindowLong(ctrl.hwnd, GWL_STYLE, dwStyle Or ES_NUMBER) End Sub Infine fai modo di associare una textbox a quella che diventa una finestra a tutti gli effetti: LeggiNumeri MiaTextBox CIAO! gino <ugino@libero.it> wrote in message bdaP7.960$1o4.49041@twister2.libero.it... > potresti provare cos� > > Private Sub Text1_KeyPress(KeyAscii As Integer) > > Select Case KeyAscii > Case 48 To 57 > ' per tasti numerici da 0 a 9 > Case 8 > ' per il tasto Canc > Case Else > ' per tutti gli altri tasti > Beep > KeyAscii = 0 > End Select > > End Sub > > buon lavoro > "Paolo" <paomal@libero.it> ha scritto nel messaggio > news:hsfJ7.109421$sq5.5213750@news.infostrada.it... > > Sono un neofita di VB6, lo sto' praticando da poco tempo e ho > > bisogno di una mano da qualcuno piu' esperto di me. > > Vorrei fare in modo che in una o piu' textbox possa solo digitare > > numeri e non lettere e che quando sbaglio mi appaia un messaggio > > di errore. > > Vi Ringrazio anticipatamente > > Paolo > > > > > > > > > > > > >
Technical Details
Message-ID:
<DRC98.55258$nI1.1605772@twister1.libero.it>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!supernews.com!news-out.visi.com!hermes.visi.com!news.maxwell.syr.edu!nntp.infostrada.it!twister1.libero.it.POSTED!not-for-mailReferences:
<hsfJ7.109421$sq5.5213750@news.infostrada.it> <bdaP7.960$1o4.49041@twister2.libero.it>Show Full Headers
Complete Article Headers
X-Google-Language: ITALIAN,ASCII X-Google-Thread: f94ee,7489f85d3f50b932 X-Google-Attributes: gidf94ee,public X-Google-ArrivalTime: 2002-02-10 14:54:09 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!supernews.com!news-out.visi.com!hermes.visi.com!news.maxwell.syr.edu!nntp.infostrada.it!twister1.libero.it.POSTED!not-for-mail From: "Max" <shaolinlohan@supereva.it> Newsgroups: free.it.visual-basic References: <hsfJ7.109421$sq5.5213750@news.infostrada.it> <bdaP7.960$1o4.49041@twister2.libero.it> Subject: R: Lettere e Numeri Lines: 71 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Message-ID: <DRC98.55258$nI1.1605772@twister1.libero.it> Date: Sun, 10 Feb 2002 22:53:23 GMT NNTP-Posting-Host: 151.24.0.42 X-Complaints-To: abuse@libero.it X-Trace: twister1.libero.it 1013381603 151.24.0.42 (Sun, 10 Feb 2002 23:53:23 MET) NNTP-Posting-Date: Sun, 10 Feb 2002 23:53:23 MET Organization: [Infostrada]