Results 1 to 11 of 11

Thread: can someone please tell me what I am doing wrong:

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    Code:
    Dim Output
    Dim intnum As Long
    Dim x
    
    Public Function FileExists(FullName As String) As Boolean
        FileExists = Len(Dir(FullName))
    End Function
    
    Private Sub Form_Load()
    If FileExists("C:\a.dat") Then
       
                   
       Dim strItem4 As String
       Open "c:\a.dat" For Input As #1
       Input #1, strItem1
       Close #1
       Label1.Caption = strItem1
      
       
    '***********************************************************************************************************************
    '***********************************************************************************************************************
         intnum = CInt(strItem1) 'I always get a type DisMatch Error Here can Someone Please tell me what I am doing wrong
    '***********************************************************************************************************************
    '***********************************************************************************************************************
         intnum = intnum + 1
         Label1.Caption = CStr(intnum)
    
    
                   Open "c:\a.dat" For Output As #1
                   Print #1, Label1.Caption
                   Close #1
    
    
    ProgressBar1.Value = Label1.Caption
    Label4.Caption = 100 - Label1.Caption
    
                 Else:
                 
                    Label1.Caption = "1"
                   Open "c:\a.dat" For Output As #1
                   Print #1, Label1.Caption
                   Close #1
                   
    
    ProgressBar1.Value = Label1.Caption
    Label4.Caption = 100 - Label1.Caption
    End If
    End Sub
    
    Private Sub Label1_Change()
    If Label1.Caption = "100" Then
    Open "C:\a.dat" For Output As #1
    Print #1, "100"
    Close #1
    End
    End If
    End Sub
    NXSupport - Your one-stop source for computer help

  2. #2
    Lively Member
    Join Date
    Jul 2000
    Posts
    94
    Chances are whatever is in strItem1 is not a number. Try doing this
    if IsNumeric(strItem1) then _
    intnum = CInt(strItem1)

    see what happens


    Cthulhu Dragon

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    no, it is numberic
    NXSupport - Your one-stop source for computer help

  4. #4
    Lively Member
    Join Date
    Jul 2000
    Posts
    94
    Did you try using the CLng function instead of CInt? I wouldn't imagine it would make much difference, but you never know.

  5. #5
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>


    Dim strItem4 As String
    Open "c:\a.dat" For Input As #1
    Input #1, strItem1
    Close #1
    Label1.Caption = strItem1

    try
    stritem1 = Cint(stritem)
    intnum = strItem1)
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  6. #6
    New Member
    Join Date
    May 2000
    Posts
    4
    Originally posted by dimava
    Code:
    Dim Output
    Dim intnum As Long
    Dim x
    
    '<<<<  Here I would remove this function entirely..seems 
    'a waste of code to me...>>>>
    
    Public Function FileExists(FullName As String) As Boolean
        FileExists = Len(Dir(FullName))
    End Function
    
    Private Sub Form_Load()
    '<<<< Here you can simply say:
    '     If Dir("C:\a.dat") <> "" Then >>>>
    
    If FileExists("C:\a.dat") Then
       
                   
       Dim strItem4 As String 
       Open "c:\a.dat" For Input As #1
       Input #1, strItem1
       Close #1
       Label1.Caption = strItem1
      
    '<<<< Can you see label1 change before it gives you 
    'the error?  If not put a:
    'Debug.print strItem1
    'and make sure its giving you a value>>>>
    
    '<<<<And lastly... Cint takes a variant and turns it into a 'Integer, but you declare strItem1 as a string, try using:
    
    'intnum = Int(strItem1) 
    
    'Instead, that takes an integer from a string..>>>>>
    
    
    '***********************************************************
         intnum = CInt(strItem1) 'I always get a type DisMatch Error Here can Someone Please tell me what I am doing wrong
    '***********************************************************     
         intnum = intnum + 1
         Label1.Caption = CStr(intnum)
    
    
                   Open "c:\a.dat" For Output As #1
                   Print #1, Label1.Caption
                   Close #1
    
    
    ProgressBar1.Value = Label1.Caption
    Label4.Caption = 100 - Label1.Caption
    
                 Else:
                 
                    Label1.Caption = "1"
                   Open "c:\a.dat" For Output As #1
                   Print #1, Label1.Caption
                   Close #1
                   
    
    ProgressBar1.Value = Label1.Caption
    Label4.Caption = 100 - Label1.Caption
    End If
    End Sub
    
    Private Sub Label1_Change()
    If Label1.Caption = "100" Then
    Open "C:\a.dat" For Output As #1
    Print #1, "100"
    Close #1
    End
    End If
    End Sub



    'Hope this helps!!

  7. #7
    Addicted Member
    Join Date
    May 2000
    Location
    Westminster, Md.
    Posts
    163
    It may be a number but a number is not always a number...if a number is a "1" then it's concidered a string and VB tends to flip out.. however if it's just a 1 then it's a number...Part of it is because + can be used the same as &

    Example:

    "1" + "1"=11
    1+1=2

    1 x 1=1

    "1" x "1"=Mismatch... cuz you can't multiply a text string times a text string.

    Eiredrake

  8. #8
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Actually, Dimava, I cut and pasted your code and it
    runs just fine...no errors...perhaps you need to
    check the contents of your file.

    If when you write to the file you use the
    Write #1, mydata
    you will get "4"

    If you use the
    Print#1, mydata
    you will get a 4




    [Edited by HeSaidJoe on 07-27-2000 at 03:15 PM]
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    I found my error, it was this 1 huge mistake that I made, but everything works fin now, thanks for all your help
    NXSupport - Your one-stop source for computer help

  10. #10
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    Hate to be picky, Dimava, but:

    1 - 1 = 0
    1 % 1 = 0.01

    I'm sure if you take extra maths classes, you'll cope just fine.
    Courgettes.

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    Yea I know but that what they teached us in 7th grade (its a joke)
    NXSupport - Your one-stop source for computer help

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