|
-
Jul 27th, 2000, 01:04 PM
#1
Thread Starter
Frenzied Member
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
-
Jul 27th, 2000, 01:12 PM
#2
Lively Member
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
-
Jul 27th, 2000, 01:15 PM
#3
Thread Starter
Frenzied Member
NXSupport - Your one-stop source for computer help
-
Jul 27th, 2000, 01:20 PM
#4
Lively Member
Did you try using the CLng function instead of CInt? I wouldn't imagine it would make much difference, but you never know.
-
Jul 27th, 2000, 01:22 PM
#5
_______
<?>
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
-
Jul 27th, 2000, 01:33 PM
#6
New Member
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!!
-
Jul 27th, 2000, 02:11 PM
#7
Addicted Member
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
-
Jul 27th, 2000, 02:12 PM
#8
_______
<?>
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
-
Jul 27th, 2000, 02:14 PM
#9
Thread Starter
Frenzied Member
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
-
Jul 27th, 2000, 02:38 PM
#10
Fanatic Member
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.
-
Jul 27th, 2000, 02:42 PM
#11
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|