Results 1 to 2 of 2

Thread: MartinLiss...why bad code?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2000
    Posts
    537
    (from earlier thread)
    ___________________________________________________
    Private Sub Text2_KeyPress(KeyAscii As Integer)
    Dim num As Integer num = Val(Text2.Text)
    if KeyAscii = 13 Then
    Label1.Caption = num + 5
    End If
    End Sub
    _________________________________
    Megatron

    ________________________________________
    'm sorry to disagree, but while it is poor code, the line num = text2.text will work just fine as long as the string is a numeric character or characters.
    __________________ Marty


    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    This is what you said in response to Megatron.
    All I want to know is WHY is it poor code? How could you make in "unpoor?"

    thanks
    pnj

  2. #2
    Guest
    I think he means that wroking with Strings and Numbers is poor code.

    You can make it unpoor by converting your Strings to numbers before you plan to work with them. As shown above, num = Val(Text1) would be an example of unpoor code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width