Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 21st, 2003, 02:57 PM
Jenny_toronto Jenny_toronto is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 3 Jenny_toronto User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Jenny_toronto
need bad help pls

4) Make sure that only letters are entered into the name text boxes. Print an error message if this is not the case: “First Name and Last Name must only contain alpha characters”.

5) Make sure that only numbers are entered into the number1 and number2 text boxes. Print an error message if this is not the case: “Number1 and Number2 must contain only numerics”.

6) The Postal Code textbox should only accept 6 characters.

7) The Number1 textbox should only accept 2 characters. The Number2 textbox should only accept 1 character.

8) The info.asp script will display the following in the browser.

(use a loop to print your name Number2 times, each name separated by 3 spaces)
Your full name is:
firstname lastname firstname lastname firstname lastname
(print out names in lowercase letters)
Your name was printed: Number2 times

The last 3 characters of your Postal Code are: (print the result).

The length of your first and last name is (print the result) characters.

(print number1) x (print number2) = (print result)

Your address (print address) has/does not have the letter E in it.

Number 2 can represent: (print number2 followed by a decimal and two zeros. Include a dollar sign in front of number2).

The random number (Print a random number between 1 and 10) multiplied by (print number 1) is: (print result)


__________________________________________________ __

This is my task that i have to do.......so far i've gotten some of the codes but most of it still doesnt work.....please help me on this..i just started this course and its getting complicated....any kind person help me

thanks

Reply With Quote
  #2  
Old October 21st, 2003, 09:51 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 29 m 58 sec
Reputation Power: 181
A crosspost is not necessary, and your subject line is not good.

Reply With Quote
  #3  
Old July 23rd, 2005, 08:51 AM
Gary O'Connor Gary O'Connor is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Cookamidgera, a little village in the centre of New South Wales, Australia. Sydney is my states capital city.
Posts: 5 Gary O'Connor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 2 m
Reputation Power: 0
Hi there,
You have a number of problems to solve but I'll give you two ways to solve the problems of only letters or numbers in the text box.

This first method requires that you declare two strings and then fill those strings with the numbers, or letters that you want to allow into each text box.

Public ChkAlph As String
Public ChkNum As String
ChkAlph = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX YZ"
ChkNum = "1234567890"

Private Sub Text1_Keypress(KeyAscii As Integer) ' Assuming you want letters in this textbox
Dim a As String, res As Variant
a = Chr$(KeyAscii)
res = InStr(ChkAlph, a)
If res = 0 Then 'This is not a letter
KeyAscii = 0 'Cancel the keypress
Call MsgBox("You can only enter alphabetical characters into this textbox!", vbCritical, "Letters Only Please!")
End If
End Sub

Private Sub Text2_Keypress(KeyAscii As Integer) ' Assuming you want numbers in this textbox
Dim a As String, res As Variant
a = Chr$(KeyAscii)
res = InStr(ChkNum, a)
If res = 0 Then 'This is not a number
KeyAscii = 0 'Cancel the keypress
Call MsgBox("You can only enter numerical characters into this textbox!", vbCritical, "Numbers OnlyPlease!")
End If
End Sub


The other method requires much less coding because we'll use the value of the Keyascii variable directly, to match the Ascii value of the key pressed.


Private Sub Text3_Keypress(KeyAscii As Integer) ' Assuming you want numbers in this textbox
If ((KeyAscii > 64) And (KeyAscii < 91)) Or ((KeyAscii > 96) And (KeyAscii < 123)) Then 'This is a letter
KeyAscii = 0 'Cancel the keypress
Call MsgBox("You can only enter numerical characters into this textbox!", vbCritical, "Numbers Only Please!")
End If
End Sub

Private Sub Text4_Keypress(KeyAscii As Integer) ' Assuming you want letters in this textbox
If (KeyAscii > 47) And (KeyAscii < 58) Then 'This is a number
KeyAscii = 0 'Cancel the keypress
Call MsgBox("You can only enter alphabetical characters into this textbox!", vbCritical, "Letters Only Please!")
End If
End Sub


Although the second method requires less coding, the first method is much more flexible and user friendly because you can format the string to contain all the characters you want just by typing them there.

For instance, the string used for numerical values should probably contain a period, for decimal calculations, and the hyphen for negative values whereas the string for alphabetical values could probably contain at least a space, a comma and a period. Using the first method you would just type these extra characters into the string and it's done.

In the second method you would have to find the ascii value of these extra characters and then change the 'If/Then' statement to include them.

To set a maximum number of entries into a textbox just set the MaxLength property of the Textbox to your required length.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > need bad help pls


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT