Results 1 to 14 of 14

Thread: Combining Vb6 and C++

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    12

    Talking Combining Vb6 and C++

    well, i need help sorta. here is what happened and some background info:
    well, im a freshman in highschool, and i took one introductory course which was vb6 and another introductory course which was c++. they are both very basic. im already done with the vb6 one and im currently near the end of the c++ one. my teacher gave us a final project which was basically to create an atm machine like program. it has to be able to create 2 acconts. then u have to login using the pin number, it has to check if valid, then it allows u to deposit money, check balance, and withdraw money. well then came to my mind the idea that i could make it look nice with gui if i combined vb6 with c++. this was quite stressing on me beacuse i just started the project 2 nights before it was due..... well, my main idea was that vb would recieve input,write to file, then open up the c++ exe, it would calc, return a value into file, and vb would read. this was very ...um....not-good. i was wondering if there was other ways i could have done it compared to my code. ill upload my code. each c++ component is in a folder and the vb project file thing isn't in a folder, its jsut there. they dont work unless all the exe's(including vb's exe) is in one folder. i also included a folder with all the exe's, like i mentioned. in that foler you just have to open "final.exe". well, please help me find more efficient ways of doing what i did, and show me new stuff. thanks

    p.s., its not long or diff. code i used, incase u expect it to be annoying and tedious, its not. its very simple. hehe.

    note: i uploaded the rar on rapidshare becuz it was too big for this upload thing. the link is this: http://rapidshare.com/files/35659825...chine.rar.html

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Combining Vb6 and C++

    Why not write a DLL in C++ and call it from the VB program? Its exactly like calling an API from VB except the DLL is in the same folder as the executable.. and thats reflected in the declaration..

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    12

    Re: Combining Vb6 and C++

    i wish i knew how to do either haha. im a newbie to programming. lolz. and other than that, does the code look good? also, im working on a new project for a local gas station. they want me to make a program that basically store the info of an unlimited amount of cusomers. this includes like name last name address etc. well, i dont kno hwo to do that in vb so i decided to use a process similar to my atm machine thing. vb will append to a file and cpp will add it all to a dynamic 2d aray. im using dynamic so it can be really big..thats the only reason haha. i figured out on paper how i could make a serch function by getting a person's first and last name, but ive run into 2 problems. the part w/ dynamic array is very slow, beacuse its huge. [10000] by [10000]. but its sooo slow, so i imagine searching it would be even slower, especially when ill have to search thru like 8 or 10. thats my first problem. my second problem is that the gas station cashes checks, so they were saying that they also need that the program would be able to take the images of the scanned check and store that too. and i dont kno how to store images. only text. the way im going about this so far is similar to that atm thing above. please help.

  4. #4
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802

    Re: Combining Vb6 and C++

    Are you sure you aren't in over your head with this one?

    For storing stuff like that I would use a database like mySQL
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

  5. #5
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Combining Vb6 and C++

    I'm with McCain on this one.. you shouldn't have taken the job. I also agree that something like that requires a database for any sort of performance.

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  6. #6

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    12

    Re: Combining Vb6 and C++

    hehe........o well...the deed is done...now i have to figure out how to use a database...any ideas for where i shold learn from?

    also, what about random access files w/ c++? u think that would work? the only thing that i think ill have a problem with is the images...i have an idea but only as a last resort
    Last edited by doyer; Jun 7th, 2007 at 11:09 AM.

  7. #7
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802

    Re: Combining Vb6 and C++

    For something as important as a business program you shouldn't use a hack job solution like communicating with text files between programs. I think your best bet is to implement all of this in Visual Basic since that's probably easier than doing it all in c++.
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

  8. #8

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    12

    Re: Combining Vb6 and C++

    well its not something that important cuz i kno the owner personally, and he just wanted something quick and dirty as long as it works and has some gui to it. and i think i might have figured it out. im using dynamic 2d arrays w/ pointers and all. to make sure i dont use any morememory thatn i need to, i first calculate how many first names there are. then i take that amount, split it in half using integer divison, and then add one. that is the size of each dimension of the 2d array. (like lets say there are 5 names, it would be like array[2+1][2+1]). and so far i also got the search function to work, where vb would write to a file what first name and last name to search for, then c++ would figure out what place in the file it is. to do this, first i took into account that there may be people w /the same first name or the same last name, so first it loads all names to arays. then it finds all the places with that first name. it does the same with the last name. then it compares , if any of the places in the 2 arrays are the same. if they are, then that particual lastname and first name belong to one person and the place is writen to a file. then it takes all the different info about that person, loads to arrays, then it finds what info corresponds to that place, then it writes all that info to one .dat file, where vb reads it. the location in both the text file and the array (if loaded into array) is also written to a text file. this way if the person should choose to edit info, c++ would load all into arrays, then change the existing data in that spot of array with the new info, and we already kno where in the array it is because it has been written to a file. then at the end, when the exit button is clicked, all the temporary files are deleted, leaving only the important stuff.


    btw mccain, luv the joke in ur sig thing..or w/e its called.

  9. #9
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Combining Vb6 and C++

    Why are you having C++ do such trivial things? Oh, and it seems to me the only pointers you're using in the C++ version are the arrays.

    Dynamic arrays, in any language, are memory heavy. In Visual Basic, the machine copies the contents of array A to a new array (array B). Then, it resizes array A to the new size, then copies array B back into array A, before destroying array B. You can see how that would effect performance. This is where you'd normally use a list in C++.. or a vector even.

    EDIT: Oh, and you can only continue to resize the second dimension in a 2D array in VB.

    You said earlier the owner needs it to be able to handle an unlimited amount of customers. Once that amount gets past say, 50-100 customers, both your VB and C++ programs will start to fail. Unless he has a NASA supercomputer able to perform the calculations required while trying to search and edit through huge text files.. you should definately consider switching everything into VB, and using a database connection.

    I would consider it sloppy programming to try and combine the two languages.. I'm not sure how anyone else feels on that subject.. feel free to chime in guys

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  10. #10
    New Member
    Join Date
    Jun 2007
    Posts
    1

    Re: Combining Vb6 and C++

    I agree with ya chem. It seems pointless to mix the languages, and it adds more complexity than is necessary.

    Sure you could use MFC to build a GUI and do the whole app in C++ but you'd probably end up with a fairly protracted development time. VB (especially .NET) is great at GUI's and Database access so id suggest you go for VB to do your program.

  11. #11

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    12

    Re: Combining Vb6 and C++

    i guess this is where i try to figure out where to learn database programming w/ vb6...considering i dont have .net..and dont kno how to use .net anyways.

    edit: any idea where i can find a tutorial to learn to use access w/ vb6? i been using google but i cant find anything. lol, cuz i think iill take ur advise and just use vb...even tho i got soo far in the c++ code..hahaha....and it took me forever to figure it all out.. o well....yeah...srry if im a noob and ask too mcuh stuff that seems stupid....please help me. thanks
    Last edited by doyer; Jun 8th, 2007 at 03:22 PM.

  12. #12

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    12

    Re: Combining Vb6 and C++

    Quote Originally Posted by chemicalNova
    Why are you having C++ do such trivial things? Oh, and it seems to me the only pointers you're using in the C++ version are the arrays.

    Dynamic arrays, in any language, are memory heavy. In Visual Basic, the machine copies the contents of array A to a new array (array B). Then, it resizes array A to the new size, then copies array B back into array A, before destroying array B. You can see how that would effect performance. This is where you'd normally use a list in C++.. or a vector even.

    EDIT: Oh, and you can only continue to resize the second dimension in a 2D array in VB.

    You said earlier the owner needs it to be able to handle an unlimited amount of customers. Once that amount gets past say, 50-100 customers, both your VB and C++ programs will start to fail. Unless he has a NASA supercomputer able to perform the calculations required while trying to search and edit through huge text files.. you should definately consider switching everything into VB, and using a database connection.

    I would consider it sloppy programming to try and combine the two languages.. I'm not sure how anyone else feels on that subject.. feel free to chime in guys

    chem
    i was confused what u were talking about in trivial things etc. now i get ur talking about my original atm thing. i was using c++ for the stupid stuff because it was for a class....and the class was a c++ class. but i got bored and decided to try and use vb and still get poitns cuz c++ does all the calculations.

  13. #13
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802

    Re: Combining Vb6 and C++

    For the vb questions I think you are better off in the vb parts of these forums...
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

  14. #14

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    12

    Re: Combining Vb6 and C++

    whoops, srry. i forgot that this was the c++ part.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width