Article View: pl.comp.lang.vbasic
Article #92474Re: Pole tekstowe
From: skyblast
Date: Mon, 31 Oct 2005 20:42
Date: Mon, 31 Oct 2005 20:42
56 lines
2850 bytes
2850 bytes
stayheavy napisał(a):
> Użytkownik "skyblast" <skyblast@linuxmail.org> napisał w wiadomości
> news:dk5al1$2kr$1@nemesis.news.tpi.pl...
>
>>Do blokowania wprowadzania liter w texbox-y używam czegoś takiego:
>>
>>Private Sub TextBox_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
>> If Not (IsNumeric(Chr(KeyAscii))) Then KeyAscii = 0
>> If IsNull(TextBox.Text) = True Then KeyAscii = 48
>>End Sub
>
>
> No niestety, nie dziala :/. Pojawia sie kominukat ze typ nie zosta wczesniej
> zdefiniowany. Mozliwe ze robie jakis blad, bo dopiero raczkuje w VB. Moj kod
> podpiety pod pole tekstowe wyglada tak:
>
> Private Sub Text2_Change()
>
> If Text2.Text < 0 Then
> MsgBox ("The value must be from the range 0-255")
> Tex2.Text = 0
> ElseIf Text2.Text > 255 Then
> MsgBox ("The value must be from the range 0-255")
> Text2.Text = 0
> End If
>
> HScroll1.Value = Text2.Text
>
> End Sub
>
> Myslalem zeby uzyc czegos takiego:
>
> If Not IsNumeric(Text2.Text) Then Text2.Text = ""
>
> ale tez nie dziala.
>
> Wartosc pola tekstowego, z racji tego czym jest, domyslnie chyba jest
> deklarowana jako String. W moim wypadku samoczynnie sie przedeklarowala na
> format numeryczny dzieki tym porownaniom <>0. Moze bredze bo nie znam
> tematu, ale nie da sie zadeklarowac na stale tego pola jako tekstowe?
> Idealem byloby zblokowanie liter, ale nie mam pojecia jak to zrobic zeby
> dzialalo.
>
> Pozdr
>
> stayheavy
>
>
Mój, błąd - podałem Ci sposób działający pod VBA Excela, spróbuj tego:
Private Sub Text2_KeyPress(KeyAscii As Integer)
If Not (IsNumeric(Chr(KeyAscii))) Then KeyAscii = 0
If IsNull(Text2.Text) = True Then KeyAscii = 48
End Sub
I daj znać czy poszło. Pozdrawiam.
Technical Details
Message-ID:
<dk5vip$njq$1@atlantis.news.tpi.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!mat.uni.torun.pl!news.man.torun.pl!newsfeed.pionier.net.pl!news.nask.pl!news.nask.org.pl!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mailReferences:
<dk58kf$8lp$1@atlantis.news.tpi.pl> <dk5al1$2kr$1@nemesis.news.tpi.pl> <dk5c96$7ll$1@nemesis.news.tpi.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!mat.uni.torun.pl!news.man.torun.pl!newsfeed.pionier.net.pl!news.nask.pl!news.nask.org.pl!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mail From: skyblast <skyblast@linuxmail.org> Newsgroups: pl.comp.lang.vbasic Subject: Re: Pole tekstowe Date: Mon, 31 Oct 2005 21:42:01 +0100 Organization: tp.internet - http://www.tpi.pl/ Lines: 56 Message-ID: <dk5vip$njq$1@atlantis.news.tpi.pl> References: <dk58kf$8lp$1@atlantis.news.tpi.pl> <dk5al1$2kr$1@nemesis.news.tpi.pl> <dk5c96$7ll$1@nemesis.news.tpi.pl> NNTP-Posting-Host: host-ip116-239.crowley.pl Mime-Version: 1.0 X-Trace: atlantis.news.tpi.pl 1130791321 24186 62.111.239.116 (31 Oct 2005 20:42:01 GMT) X-Complaints-To: usenet@tpi.pl NNTP-Posting-Date: Mon, 31 Oct 2005 20:42:01 +0000 (UTC) User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: pl, en-us, en In-Reply-To: <dk5c96$7ll$1@nemesis.news.tpi.pl> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit