Results 1 to 2 of 2

Thread: conversion type error

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2004
    Location
    in the heart of the Mediterranean
    Posts
    1,143

    conversion type error

    I am getting a conversion type error on the red line, can someone pls help?

    Code:
    Private Function GetGap() As Integer
    
    Dim VowelNumG As Integer
    Dm Vowels as string = "AEIOU"
    Dim VowelIndexG as integer
    
            For VowelIndexG = RandomStr.Length - 1 To 0 Step -1
                Do While VowelNumG < 5 And VowelIndexG <> (RandomStr(0))
                    If Vowels.Contains(RandomStr.Substring(VowelIndexG, 1).ToUpper) Then
                        VowelNumG += 1
                        If VowelNumG = 3 Then
                            'MsgBox("Third vowel is " & RandomStr.Substring(VowelIndexG, 1) & "Char number is the " & (VowelIndexG) & "in the string")
                            Return VowelIndexG
                            Exit Function
                        End If
                    End If
                Loop
    
            Next
    
        End Function
    ------------------------------------------------------------------------
    If an answer to your question has been helpful, then please, Rate it!

  2. #2
    Fanatic Member Vectris's Avatar
    Join Date
    Dec 2008
    Location
    USA
    Posts
    941

    Re: conversion type error

    Your comparing an Integer (VowelIndexG) with a string (RandomStr(0)).

    You can convert an Integer to a string with .ToString() or from a string to an integer with CInt()
    If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved!

    If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job

    __________________
    My Vb.Net CodeBank Submissions:
    Microsoft Calculator Clone
    Custom TextBox Restrictions
    Get the Text inbetween HTML Tags (or two words)

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