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
202 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

895 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now