Skip to main content

Posts

Showing posts from March, 2013

Find the bug in the following code.

This code opens / creates / reads and writes / appends to text files as specified by the user. Assuming that the user has entered numeric, comma-separated data, the GetRange module calculates the range and the range coefficient (lookup Statistics - Measures of Dispersion Std XI). Somewhere in this last bit the program does a few mistakes. Imports System.io Public Class FileOps     Public Response As Integer     Private Sub ReadFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReadFile.Click         MyFileData.Clear()         If CreateFile() > -1 Then MyFileData.Text = File.ReadAllText(MyFilePath.Text)     End Sub     Private Sub SaveToFile_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SaveToFile.Click         If CreateFile() = -1 Then Exit Sub         If File.ReadAllText(MyFilePath.Text).Length >= 0 Then             Response = MsgBox("The file contains something already. Do you want to overwrite? (Clicking on 'No' wil