[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 237
  • Last Modified:

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

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
michelle_branch
Asked:
michelle_branch
  • 4
  • 3
  • 2
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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
 
pg_indiaCommented:
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
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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!

 
michelle_branchAuthor Commented:
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
 
pg_indiaCommented:
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
 
michelle_branchAuthor Commented:
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
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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
 
michelle_branchAuthor Commented:
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
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now