• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 121
  • Last Modified:

check box & file operation

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
sumanths_query
Asked:
sumanths_query
1 Solution
 
sumanths_queryAuthor Commented:
can anyone pls give me the code for the operation i have requested to be performed






thanx
0
 
Ryan ChongCommented:
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
 
supunrCommented:
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
CleanupPingCommented:
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
 
DanRollinsCommented:
Moderator, my recommended disposition is:

    Save as PAQ -- No Refund.

DanRollins -- EE database cleanup volunteer
0
 
YensidModCommented:
Question is PAQ'd and no points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now