Results 1 to 26 of 26

Thread: Type mismatch

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    34

    Angry Type mismatch

    I am getting this error while trying to use the control...

    "Type mismatch "

    The function is:

    Private Sub Command1_Click()
    'ways(routeList.ListIndex).timeOpen = timeConvert(Trim(timeStart.Text))
    'ways(routeList.ListIndex).timeClose = timeConvert(Trim(timeEnd.Text))
    ways(routeList.ListIndex).timeOpen = Format(Trim(timeStart.Text), "hh:mm AMPM")
    ways(routeList.ListIndex).timeClose = Format(Trim(timeStart.Text), "hh:mm AMPM")
    target = fillTime(routeList.ListIndex)
    End Sub

    ===>The error place
    schedway = ways

  2. #2
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Type mismatch

    Quote Originally Posted by emmim44
    I am getting this error while trying to use the control...

    "Type mismatch "

    The function is:

    Private Sub Command1_Click()
    'ways(routeList.ListIndex).timeOpen = timeConvert(Trim(timeStart.Text))
    'ways(routeList.ListIndex).timeClose = timeConvert(Trim(timeEnd.Text))
    ways(routeList.ListIndex).timeOpen = Format(Trim(timeStart.Text), "hh:mm AMPM")
    ways(routeList.ListIndex).timeClose = Format(Trim(timeStart.Text), "hh:mm AMPM")
    target = fillTime(routeList.ListIndex)
    End Sub

    ===>The error place
    schedway = ways

    Two questions, first at what line do you get the error and second, what error are you getting? Please use the Highlight Tags when posting your code, it makes it a lot easier to read.
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Type mismatch

    Welcome to the forums.

    What is "the control"? What are you using?

  4. #4

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    34

    Re: Type mismatch

    I have 4 forms. When I debug, the 4th form has these line "schedway = ways"

    it goes there...I am little confuse..

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Type mismatch

    Quote Originally Posted by emmim44
    I am little confuse..
    So am I.

    What control is causing the problem?

    Also, in the code that you posted there is no mention or reference to anything that is remotely like "schedway = ways"? Where is that coming from?

  6. #6

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    34

    Re: Type mismatch

    When I clicked the change button. it throws that error..There are two text boxes that contaion such data "12:23AM" ...etc...I want to edit the value of the text boxes...when clicks the change button throw the error...I am reading the data from a txt file.

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Type mismatch

    Is this the code in the "change" button
    Code:
    Private Sub Command1_Click()
    'ways(routeList.ListIndex).timeOpen = timeConvert(Trim(timeStart.Text))
    'ways(routeList.ListIndex).timeClose = timeConvert(Trim(timeEnd.Text))
    ways(routeList.ListIndex).timeOpen = Format(Trim(timeStart.Text), "hh:mm AMPM")
    ways(routeList.ListIndex).timeClose = Format(Trim(timeStart.Text), "hh:mm AMPM")
    target = fillTime(routeList.ListIndex)
    End Sub

  8. #8

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    34

    Re: Type mismatch

    yes.

  9. #9
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Type mismatch

    Ways is what type of control (textbox, combobox,etc)?
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Type mismatch

    When you click the button, and the error message pops up, and you click on the Debug button, what line is highlighted?

  11. #11

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    34

    Re: Type mismatch

    Type is text box...It takes me here

    Private Sub Form_Load()
    schedway = ways
    For x = 0 To UBound(schedway)
    schedway(x).status = x
    Next x
    target = sortRoute()
    haltVar = 1
    dayList.ListIndex = 0
    target = fillrList()
    workList.ListIndex = 0
    haltVar = 0
    End Sub

  12. #12
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Type mismatch

    First, you didn't answer this question
    Quote Originally Posted by Hack
    When you click the button, and the error message pops up, and you click on the Debug button, what line is highlighted?
    Second, how are these variables declared:

    schedway
    ways
    target
    haltVar

  13. #13

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    34

    Re: Type mismatch

    Private Type Routes
    daysRun(7) As Integer
    timeOpen As Integer
    timeClose As Integer
    status As Integer
    name As String
    day As Integer
    End Type
    Dim schedway() As Routes
    Dim haltVar As Integer
    Dim target As Variant


    Dim wsize As Integer
    Dim wasize As Integer
    Dim r As Integer
    Dim p As String
    Dim q As String

  14. #14
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Type mismatch

    Good. We are making progress.

    Now that I know what the variables are, I should be able to spot your Type Mismatch, but I MUST know on what line the error is occuring. Then I can take a look at what variables are being used against how they have been declared.

    So, one more time
    Quote Originally Posted by Hack
    When you click the button, and the error message pops up, and you click on the Debug button, what line is highlighted?

  15. #15

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    34

    Re: Type mismatch

    The line 2 throws the error

    Private Sub Form_Load()
    schedway = ways
    For x = 0 To UBound(schedway)
    schedway(x).status = x
    Next x
    target = sortRoute()
    haltVar = 1
    dayList.ListIndex = 0
    target = fillrList()
    workList.ListIndex = 0
    haltVar = 0
    End Sub

  16. #16
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Type mismatch

    What is 'ways' - I do not see that listed in your other code with the declares.

  17. #17

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    34

    Re: Type mismatch

    Now I have defined the ways and workers as
    Dim ways() As Long
    Dim workers() As Long

    it it is giving an error "Invalid qualifier" on line 16...
    Code:
    Private Sub loadButton_Click()
    cd1.DialogTitle = "Load Data"
    cd1.Filter = "Text (*.txt)|*.txt|Data (*.dta)|*.dta"
    cd1.ShowOpen
    Open cd1.FileName For Input As #1
    Line Input #1, p
    wsize = Val(p)
    ReDim Preserve workers(wsize - 1)
    Line Input #1, p
    wasize = Val(p)
    ReDim Preserve ways(wasize - 1)
    For x = 0 To wasize - 1
    For y = 0 To 6
    Line Input #1, q
    If q = "Yes" Then
    ways(x).daysRun(y) = 1
    End If
    Next y
    Line Input #1, ways(x).name
    Line Input #1, p
    ways(x).timeOpen = Val(p)
    Line Input #1, p
    ways(x).timeClose = Val(p)
    Next x
    For x = 0 To wsize - 1
    ReDim workers(x).workDoing(0)
    ReDim workers(x).routeKnown(0)
    Line Input #1, workers(x).name
    For y = 0 To 6
    Line Input #1, p
    workers(x).workStart(y) = Val(p)
    Line Input #1, p
    workers(x).workEnd(y) = Val(p)
    Line Input #1, p
    workers(x).work(y) = Val(p)
    Line Input #1, p
    workers(x).deadStart(y) = Val(p)
    Line Input #1, p
    workers(x).deadEnd(y) = Val(p)
    Line Input #1, p
    workers(x).dead(y) = Val(p)
    Next y
    Dim putter As String
    Dim cntr As Integer
    cntr = 1
    For z = 0 To wasize - 1
    Line Input #1, putter
    If putter = "Yes" Then
    ReDim Preserve workers(x).routeKnown(cntr)
    workers(x).routeKnown(cntr) = ways(z)
    cntr = cntr + 1
    ElseIf putter = "Train" Then
    ReDim Preserve workers(x).routeKnown(cntr)
    workers(x).routeKnown(cntr) = ways(z)
    workers(x).routeKnown(cntr).status = 0
    cntr = cntr + 1
    End If
    Next z
    
    Line Input #1, q
    r = Val(q)
    ReDim Preserve workers(x).workDoing(r)
    For y = 1 To r
    Line Input #1, p
    Line Input #1, q
    For z = 0 To wasize - 1
    If ways(z).name = p Then
    workers(x).workDoing(y) = ways(z)
        workers(x).workDoing(y).day = Val(q)
    End If
    Next z
    Next y
    Next x
    Close #1
    End Sub
    Last edited by Hack; Aug 2nd, 2007 at 01:48 PM. Reason: Added Code Tags

  18. #18
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Type mismatch

    Quote Originally Posted by Hack
    What is 'ways' - I do not see that listed in your other code with the declares.
    Quote Originally Posted by Mark Gambo
    Ways is what type of control (textbox, combobox,etc)?
    I asked the same thing in Post #9
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  19. #19

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    34

    Re: Type mismatch

    it is an array combobox

  20. #20
    Hyperactive Member
    Join Date
    Aug 2007
    Posts
    259

    Re: Type mismatch

    Quote Originally Posted by emmim44
    I am getting this error while trying to use the control...

    "Type mismatch "

    The function is:

    Private Sub Command1_Click()
    'ways(routeList.ListIndex).timeOpen = timeConvert(Trim(timeStart.Text))
    'ways(routeList.ListIndex).timeClose = timeConvert(Trim(timeEnd.Text))
    ways(routeList.ListIndex).timeOpen = Format(Trim(timeStart.Text), "hh:mm AMPM")
    ways(routeList.ListIndex).timeClose = Format(Trim(timeStart.Text), "hh:mm AMPM")
    target = fillTime(routeList.ListIndex)
    End Sub

    ===>The error place
    schedway = ways
    is there supposed to be a ' there?

  21. #21

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    34

    Re: Type mismatch

    The commented the ones are the original ones but I was still getting the same error..I need a solution dudes..You are the genius..

  22. #22
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Type mismatch

    I'm guessing the problem has to do with this:

    Dim ways() As Long
    ...
    ways(x).daysRun(y) = 1

    Long variables don't have any properties. They definitely do not have a "daysRun()" array property.

  23. #23

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    34

    Re: Type mismatch

    I am sorry in the module.bas These are defined as

    Private Type Routes
    daysRun(7) As Integer
    timeOpen As Integer
    timeClose As Integer
    status As Integer
    name As String
    day As Integer
    End Type
    Private Type driver
    name As String
    workStart(7) As Integer
    workEnd(7) As Integer
    work(7) As Integer
    dead(7) As Integer
    deadStart(7) As Integer
    deadEnd(7) As Integer
    routeKnown() As Routes
    workDoing() As Routes
    End Type
    Global workers() As driver
    Global ways() As Routes

  24. #24

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    34

    Re: Type mismatch

    After all.
    The error line is 8:::

    Function timeConvert(given)
    Dim a As Integer
    Dim b As Integer
    Dim time As String
    time = Replace(given, "AM", "")
    time = Replace(given, "PM", "")
    time = Replace(given, ":", "")
    a = time / 100
    b = given Mod 60
    time = "AM"
    If a = 0 Then
    a = 12
    End If

    If a > 12 Then
    a = a - 12
    time = "PM"
    End If

    If b < 10 Then
    Dim c As String
    time = Str(a) + ":" + "0" + Replace(Str(b), " ", "") + time
    Else
    time = Str(a) + ":" + Replace(Str(b), " ", "") + time
    End If
    timeConvert = time
    End Function
    Function routeEqual(given1, given2)
    given1.timeOpen = given2.timeOpen
    given1.timeClose = given2.timeClose
    given1.status = given2.status
    given1.name = given2.name
    given1.day = given2.day
    For x = 0 To 6
    given1.daysRun(x) = given2.daysRun(x)
    Next x
    End Function

  25. #25
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Type mismatch

    In a nutshell, what is TimeConvert() supposed to do?

  26. #26

    Thread Starter
    Member
    Join Date
    Aug 2007
    Posts
    34

    Re: Type mismatch

    TimeConert the minutes(1680 minutes) format time into a real time format...

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