Need to find An Online advertisement?

Need code for VB program that will Graph in Excel! Form/Layout done - need code

  • Hello ? I am trying to make a program for work to graph some data a machine outputs. I have already made the form in VB, and just need some code to make it work. I am also including an excel file that I made with the graph I made with the data. In a nutshell, the program needs to find the *.txt file inputted by the user, either through a direct text type-in in the text box provided on the form, or the user can browse for the file in the c:\pl folder or anywhere else if needed, but default first browse for file in the c:\pl folder. These *.txt files are files with different names outputted by the machines, so there won't be a set series name on it, this is why we have to search or input search it. This text file, whatever it is called, the one I am including is called transitionsw-light2.txt ? this file is formatted 2 columns - time(secs) & channelA. I need the user to be able to click on ?Graph in Excel? and here?s where the major coding begins ? the program needs to be able to fill the data from the .txt file into a spreadsheet ? see the attached graphing550nm.xls for an example of the layout, then somehow excel (or vb ? I?m not sure how this would work so up to you however you think is best) will graph this data ? column A and B in excel. See the chart1 in excel for the graph I already made for layout. This is how I would like the data to be filled in. Then back to my VB form I made ? if the user clicks on ?save? the program will save the form in excel ? I guess just bring up the excel save function when this is clicked, so the user can define where he/she would like to save it, and defaulting the save name to whatever the *.txt name inputted to keep it simple ? but allow changes if needed. The ?view? button would just open the graph/spreadsheet in excel. The ?print? button will print the graph/spreadsheet from excel. The ?clear data? button will allow the user to do the graphing again but with a different file without having to exit, start again. If the user hasn?t saved yet, maybe have a prompt to ask them to save before clear. The user can end with the end button, also, if user hasn?t saved yet give them an option to. That?s it - Let me know if you need more information/clarification. Thanks! Here are the files (it is off a free webhost on the web, so scroll down to where it says "download free" for files, because it might look like a giant advertisement at first since it has lots of banners to allow it as a free service) VB zipped files: http://rapidshare.de/files/5321903/GRAPHVB.zip.html Excel File: http://rapidshare.de/files/5322089/graphing550nm.xls.html Txt File: http://rapidshare.de/files/5322073/transitions_w-light_2.txt.html

  • Answer:

    Hi Kristalys-ga, The file is hosted here: http://pfile.net/gallery/v/Jennifer/Hosted/?g2_statusId=xd3459cbd&g2_navId=xc61d617f It?s called grapher.xls I?ll be taking it down in a month or so, so please get it saved to your hard drive. This MS Excel workbook, called Grapher, is a read only file meant to perform the actions you requested. It is a highly portable single file and will work on any machine that has an installed copy of Microsoft Excel. When a user opens the file, it's highly important their security settings for Excel allow for macros to run. (In Excel 2003, go to TOOLS > OPTIONS > SECURITY > MACRO SECURITY > SECURITY LEVEL and set it to "medium" to choose whether or not to run macros when an Excel file is opened. Macros MUST be enabled for Grapher to work) Grapher is NOT meant to store data, which is why it is read-only. It's strict function is: 1) Import data 2) View data 3) Save data to new file. ------------------------------------- Grapher contains only one sheet, called "Main". This sheet contains captioned "form" buttons that perform the following functions: File-->Graph* View Graph View Data Print Graph Print Data Save Clear Data * No other button will work unless this one is performed first! The requested "end" function is performed by closing the workbook, and is therefore not included. ------------------------------------- Each of these buttons on the sheet have a function that is described below: Function: File-->Graph When you press this button, a dialog will open that first looks in "c:\pl". If it cannot find this folder, it defaults to the current directory set in the operating system. You can navigate anywhere on your system. The two file formats you can look for is ".txt" and ".time" ? or "*.*" when you explicitly type it in. When you open the chosen file, it is imported into Grapher as a second sheet with the name of the file you chose (minus the extension). The data will be in two columns. Immediately after, a third sheet named "Graph" will appear, and this sheet will contain the graph of the data that Grapher just imported. When these actions are finished, you'll be returned to the main sheet, called "Main". If this button is pressed again, it will not allow the import of another data file. Only when Grapher contains the single "main" sheet will it be able to import a text file. Saving the workbook with these two new sheets inside will remain impossible because of the nature of Grapher as a functional (not storage) workbook. If the "read-only" attribute is removed from the file, you WILL be able to save to the Grapher workbook, although this is not recommended. Function: View Graph (Works only after importing data) Press this to view the sheet, named "Graph", which contains the graph Function: View Data (Works only after importing data) Press this to view the sheet, named after your imported text file, which contains the data for the graph. Function: Print Graph (Works only after importing data) Press this to automatically print the graph in the sheet, named "Graph", to the DEFAULT printer on your system. Function: View Graph (Works only after importing data) Press this to automatically print the data in the sheet, named after your imported text file, to the DEFAULT printer on your system. Function: Save (Works only after importing data) When you press this, a dialog will appear to save your file. The path is still where the operating system was when we imported the file. The default file name is identical to the file name of the imported text file. The only format you'll be allowed to save in is XLS (an Excel workbook). When you are satisfied with the location and name of the file that will contain the graph and the data, press "save" in the dialog. The sheet named "Graph" and the sheet named after your imported text file will be MOVED from Grapher to this new workbook. The new workbook is then saved. Grapher will now only contain the sheet named "Main,? and your new workbook will contain the other two sheets. Grapher is now ready to import and graph new data. When you open the workbook you saved earlier, the graph in the sheet named "Graph" will still rely on the data in the sheet whose name is identical to the new workbook's name. Function: Clear Data (Works only after importing data) Pressing this button will open a message box that asks you if you want to save your "Graph" sheet and the sheet named after the imported text file, which contains the data. The choices will be "yes,? "no", and "cancel.? Pressing "cancel" only cancels the operation. Pressing "no" will clear the two sheets from Grapher. Pressing "yes" will allow you to save the sheets into a new workbook (using the operation described above) before they are removed from Grapher. -------------------------- Please test this workbook to make sure that everything's working properly. ( I already did and had no issues?but) A good test would keep Grapher open while several imports and saves are performed on your data. Try importing a TXT file, saving the results, clearing the data, importing a TIME file, saving the results, and then doing the same things without saving the results. If you experience no issues and find it flexible enough, then Grapher is solid enough to perform your requested tasks. This should work well for you. If this answer requires further explanation, please request clarification before rating it, and I'll be happy to look into this further. Let me know if you find any bugs as well and I?ll work on those and get you an updated version. Nenna-GA Google Answers Researcher

kristalys-ga at Google Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.