|
|
|
| CE En 270 - Homework #23InputBox and String ManipulationThe following spreadsheet is designed to plot a function in terms of x:
When the user clicks on the Update button, the InputBox function is used to prompt the user for a new function. The formula is then copied into cell B4 and the x and f(x) columns are updated. The number of points in the table is equal to npts where npts is declared as a constant equal to VB code (currently = 101). The x values are set to vary linearly from xmin to xmax. The f(x) entries are updated using the Replace string function so that every instance of x in the function is replaced with a relative address to the corresponding cell in the x column. The plot is then updated. Click here to download a partially completed copy of this spreadsheet. You may wish to take a minute to see how the cells are named. Then do the following: (a). Make a call to the InputBox function to prompt for the new function at the spot marked in the code. You should pass the current contents of cell B4 as the default value to the InputBox function. Store the result of the call to InputBox in the string variable functionstring. (b). Add code to clear the contents of the table where indicated. (c). Add code to set up the values for the x column. (d). Add code to set up the values for the f(x) column. For each cell, make a string representing the address of the cell just to the left of the current cell (for example "A32"). Then use the Replace function to copy this address to all instances of x in the function string. Be sure to add an equal sign ("=") to the beginning of the formula before you copy it to the cell. Submittal Instructions:Click here to upload your homework assignment. |