Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function Checklength(S As String) As Boolean
- Dim c As Integer = 0
- Dim i As Integer = 0
- Dim L As Integer = S.Length
- Dim Yes As String
- Do While i < L
- If S.Substring(i, 1) < Asc("0") Or S.Substring(i, 1) > Asc("9") Then
- Yes = True
- Else
- i += 1
- End If
- Loop
- Return Yes
- End Function
- Private Sub Checkbutt_Click(sender As Object, e As EventArgs) Handles Checkbutt.Click
- Dim S As String
- S = InputTexttxt.Text
- Checklength(S)
- MessageBox.Show(S)
- End Sub
- End Class
- The Assignment Question-
- Write a function that checks whether a string has a number based. Use what we learned about Asc to complete the following:
- Function CheckLength (S As String) As Boolean
- ‘add a do loop to start at first character
- ‘if Ascii current character is between Asc (“0”) and Asc (“9”)
- ‘then we have a hit Return True
- ‘else check the next character
- ‘if loop is over, that means no hit was found Return False
- End Function
- Use this function in an application that allows the user to enter the string/text that should be tested by your CheckLength function.
- The problem i am having. Not usre how i can convert from string to double here.
- System.InvalidCastException
- HResult=0x80004002
- Message=Conversion from string "o" to type 'Double' is not valid.
- Source=Microsoft.VisualBasic
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement