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
206 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

821 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