web development India freelance website designer
When you retrieve a numeric value from a textbox, you may want to compare it to some other preset value. For example, consider the following code:
Select Case Text1.Text
Case 1 to 12
MsgBox "Acceptable Value"
Case Else
MsgBox "Unacceptable Value"
End Select
You might think that this code would compare a numeric value in Text1 and return Acceptable Value for values 1 through 12, and Unacceptable Value for all other numbers. Instead, this code snippet displays the Acceptable Value message for only 1, 10, 11, and 12, but not 2, 3, 4, etc. That's because a textbox's Text property returns the value as a string, and so compares them as such in the Select Case statement.
To avoid this unexpected glitch, convert the numbers with the Val() function. This function automatically converts a string into the appropriate type: integer, long, single, or double. The modified code would look as follows:
Select Case Val(Text1.Text)
Case 1 to 12
MsgBox "Acceptable Value"
Case Else
MsgBox "Unacceptable Value"
End Select
Avoid variable type comparison glitches in textbox

1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550

Freelance ASP PHP web development | Web developer India Web development India| Prayagasoft - web designer India, Ecommerce developer india, Ecommerce design