Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


file open question


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-30-2008, 03:55 AM
Junior Member
 
Join Date: May 2007
Posts: 31
Default file open question

With the below code why does the file contents like fine in the explorer (date) only but show a large number when viewed the code way ?

Sub Globals
'Declare the global variables here.
regdt=Date(Now)
End Sub
Sub App_Start
Form1.Show
reg
End Sub
Sub reg
ErrorLabel(Err1)
If FileExist ("c:\windows\colorbn.txt") = true Then
FileOpen (c1,"c:\windows\colorbn.txt",cRead)
r = FileRead (c1)
Do Until r = EOF
sum = sum + r
r = FileRead (c1)
Loop
textbox1.Text=sum
FileClose (c1)
Else
regdt=Date(Now)
FileOpen (c1,"c:\windows\colorbn.txt",cWrite)
FileWrite (c1,regdt)
FileClose (c1)
End If
Goto sbed
err1:
Msgbox("Error")
sbed:
End Sub
Reply With Quote
  #2 (permalink)  
Old 05-30-2008, 07:57 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 707
Awards Showcase
Beta Tester Competition Winner 
Total Awards: 2
Default

You should replace your code by this one.

Code:
Sub Globals
' Declare the global variables here.
  regdt=Date(Now)
End Sub

Sub App_Start
  Form1.Show
  reg
End Sub

Sub reg
  ErrorLabel(Err1)
  If FileExist ("c:\windows\colorbn.txt") = true Then 
    FileOpen (c1,"c:\windows\colorbn.txt",cRead) 
    r = FileRead (c1) 
    FileClose (c1) 
    textbox1.Text=r 
  Else 
    regdt=Date(Now)
    FileOpen (c1,"c:\windows\colorbn.txt",cWrite) 
    FileWrite (c1,regdt) 
    FileClose (c1)
  End If
  Return
err1:
  Msgbox("Error")
End Sub
I don't understand why you dit the sum ?

Best regards.
__________________
Klaus
Switzerland
Reply With Quote
  #3 (permalink)  
Old 05-30-2008, 08:28 AM
Junior Member
 
Join Date: May 2007
Posts: 31
Default thanks

thanks was using a demo in the basic4ppc manual
Reply With Quote
  #4 (permalink)  
Old 05-30-2008, 09:33 AM
Junior Member
 
Join Date: May 2007
Posts: 31
Default another question

any idea why I getting an error on this code and how to complete it, thanks !!!

Sub Globals
'Declare the global variables here.
regdt=Date(Now)
rc=0
End Sub
Sub App_Start
Form1.Show
reg
End Sub
Sub reg
Dim regexp
ErrorLabel(Err1)
If FileExist ("c:\windows\clrbn.txt") = true Then
FileOpen (c1,"c:\windows\clrbn.txt",cRead)
r = FileRead (c1)
FileClose (c1)
Else
regdt=Date(Now)
FileOpen (c1,"c:\windows\clrbn.txt",cWrite)
FileWrite (c1,regdt)
FileClose (c1)
End If
textbox1.Text=r ' Displays Registration Date
textbox3.text=Date(Now) ' Displays Today Date
rd=DateAdd(r, 0, 1, 0)'sets reg duration (Ticks, Years, Months, Days)for one month
textbox2.text=rd ' Displays Registration Expires Date
dn=Date(Now)
If dn > rd Msgbox("Registration Expired, Contact Support for Registered Version, Contact scott93727@aol.com"):rc=1 ' if date now later then regdate by 1 month
Goto sed
err1:
Msgbox("Registration Error, Contact Support, scott93727@aol.com")
sed:
'if rc=1 then (Control code (what to disable after reg. expires))
End Sub
Reply With Quote
  #5 (permalink)  
Old 05-30-2008, 10:07 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,770
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

You have posted this question in a separate thread. In the politest possible way (not easy for me I know ) could I point out that cross-posting is considered bad form in most forums/newgroups.

P.S. Your answer is in the other thread
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tippy v.1.0 [open source] N1c0_ds Share Your Creations 4 11-20-2008 10:08 PM
Automatically Open Pword With A Word File sintaq Questions & Help Needed 3 03-26-2008 03:31 PM
Serial Port won't open djmrozinski Questions & Help Needed 6 03-16-2008 05:25 PM
open a text file with Word mwaite Questions & Help Needed 6 06-16-2007 10:03 AM
SQLite Open Close - how often? sloopa Questions & Help Needed 3 05-01-2007 03:01 PM


All times are GMT. The time now is 02:43 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0