?
Solved

check box  & file operation

Posted on 2003-03-10
6
Medium Priority
?
120 Views
Last Modified: 2010-05-01
i have a check box which if i check i write a value into a file using basic file handling(not file system objects).

is it possible, if i uncheck the checkbox ,to delete the value written to the file while checking the checkbox ,thru code.

0
Comment
Question by:sumanths_query
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Author Comment

by:sumanths_query
ID: 8108104
can anyone pls give me the code for the operation i have requested to be performed






thanx
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 8108162
Try:

'!Create/Write File Content
Public Function WriteFileText(ByVal FileName As String, ByVal Source As String) As String
    On Error GoTo EHandler
    Dim Handle As Integer
    Handle = FreeFile
    Open FileName For Output As #Handle
        Print #Handle, Source
        On Error Resume Next
    Close #Handle
    Exit Function
EHandler:
    ShowErrMsg
    On Error Resume Next
    Close #Handle
End Function

In a form:

private sub command1_click()
   dim v as string
   if check1.value = 1 then v = "checked"
   
   WriteFileText "c:\abc.txt",v

end sub

Hope this helps
0
 
LVL 11

Expert Comment

by:supunr
ID: 8108245
I am not sure whether this will help you.  I am wondering, are you writing a program setting to a file?  If that is the case, why don't you write the value registry as shown below.

Private Sub Check1_Click()
     ' Save the value to the registry
     SaveSetting App.Title, "Settings", "Check1", Check1.Value
End Sub

Private Sub Form_Load()
     ' load the check box value from the registry
     ' by default it is checked
     Check1.Value = GetSetting(App.Title, "Settings", "Check1", vbChecked)
End Sub

Hope this might have given you some useful info.  Good Luck!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:CleanupPing
ID: 8900357
sumanths_query:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9074756
Moderator, my recommended disposition is:

    Save as PAQ -- No Refund.

DanRollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
YensidMod earned 0 total points
ID: 9166044
Question is PAQ'd and no points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question