Solved

How to separate a string (word) into characters in vb and also.. HELP me in this EXCEL thing...See detail..

Posted on 2003-10-27
9
208 Views
Last Modified: 2010-05-01
First i got question on seperating word into characters.
Let say i got this ----> Text1 = Visual^Basic (i use this keypress function)
So now i want it to be ----> Text1 = {V}{i}{s}{u}{a}{l}{^}{B}{a}{s}{i}{c} (meaning that adding this {} in between the characters and when i want to print out the word, it will come out exactly
{V}{i}{s}{u}{a}{l}{^}{B}{a}{s}{i}{c} )

Second question is that i got this excel file. Containing columns and rows. Let say 3 columns and 10 rows.
I need to substitute the data in the column into a formula. Each row in each column has the same format ( time, date, and value).
How i want to write a code that
       1. Get the file in the directory ( e.g : c:\excel.xls) and open/read the file (which one that necessarily)
       2. Take only data in SECOND column and it start at THIRD row. Then the process repeat for the fourth row until tenth row. When i come to the tenth row, a msgbox will pop up with certain msg.

Hope any experts here can help me :) Really appriciate!!
0
Comment
Question by:michelle_branch
  • 4
  • 3
  • 2
9 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 125 total points
ID: 9631001
First of all, you should only have on problem per question.

Here is one way to do the first part:

Private Sub Form_Load()
   MsgBox convertString("Visual^Basic")
End Sub

Private Function convertString(stringToConvert as String) As String
   Dim newString As String, a As Integer
   newString = ""
   For a = 1 to len(stringToConvert)
      newString = newString & "{" & Mid(stringToConvert, a, 1) & "}"  
   Next a
   convertString = newString
End Function
0
 
LVL 3

Expert Comment

by:pg_india
ID: 9631601
for second question:-)))

u can access excel using createobject("excel.application") or add a reference to microsft excel in your application.
then u can access the worksheet and workbook using workapp.workbooks.open("c:\1.xls")

then u can access the worksheet using workbook.worksheet..

now u can access each row and col using cell(x,y)

start a whle loopp...

I think this much frame work is enough

for 1st question:
idle_mind has already posted that...and it is working perfect...
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 9688447
How is your project coming along?
0
Industry Leaders: 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!

 

Author Comment

by:michelle_branch
ID: 9691045
my project going quite fine.. but when i try to extract data from excel file and substitute the data into a formula, the calculation of the formula becoming very slow. it took almost 100% of my computer's memory when i run the application. And it happen to be that the value/answer to the calculation come out a few  seconds after the next data is extract and the calculation also skip a few data that extracted from the excel file.
i think it is because i code my project to open the excel file that may take up my computer's memory and also maybe it took a long time to calculate using my formula ( i think the formula is just simple).
Is it possible to NOT open the excel file while running the application, just extract the data without need to open the excel file  on the desktop?
How about if i use note pad instead of excel application to extract data row by row in certain column? If possible, how is the coding? Now i kinda desperate because the due date of my project is just around the corner. Please help!

~And also, please consider this as one question.
0
 
LVL 3

Expert Comment

by:pg_india
ID: 9692176
Well if u try to open an excel file in notepad there will be many non ascii characters which you can filter but thats quite difficult

Well Excel does not take that much of space.

Well if your problem is solved i think you should give the points and ask new questions.
0
 

Author Comment

by:michelle_branch
ID: 9692555
How can i say this.. ermm.. Should i consider it work if right now i stuck with the same problem? Overall, my project going fine (although new problem occur just now). Using the coding for extract data from excel make my application seems like  to stop responding and becoming really slow that required me to stop the process halfway. it is like my application turn into white (no visual and other interface) and seconds after that, my desktop turn white and nothing i can do on my application to stop the process (like it stop responding) and i need to ctr + alt + delete and stop the excel file from loading.

i not try to raise a new question without giving points to "prevoius" question but just to tell what had happen and suggest other alternative.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 9694035
What Office Suite are you running?
What version Windows?
How much memory do you have?

How many rows, columns are you dealing with in the excel file?
0
 

Author Comment

by:michelle_branch
ID: 9697955
my comp specs :
pentium 4 1.8 ghz
ram 384 mb
windows xp
office xp

i generate 4 columns and 100 rows. I've tried with few rows (less than 10) and i do not put the extracted data into my formula. My application run well and can show the value of the data directly. Only when i substitute it into my formula it cannot run well. i've also tried to put sleep function to give time for the formula to calculate the value but still didn't work.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 9698852
The sleep function stops your app from running completely until the alotted time has expired.  This may be why your app is unresponsive.  If you have some kind of loop where you are doing calculations or are waiting for something else, then DoEvents() would probably be more appropriate.

Can you explain a little more clearly what you are calculating and how?  Perhaps there is a more efficient way to accomplish the task.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

713 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