Results 1 to 22 of 22

Thread: Is possible to combine C source code with Visual Basic 6?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2016
    Posts
    89

    Is possible to combine C source code with Visual Basic 6?

    Hi!

    I need to use source code written in C with my application whch is written in Visual Basic 6.
    I have no choice, I don't know C and must to use existing.

    Is possible to combine C and VB6 code in single application?

    Thank you for each help.
    Miro

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: Is possible to combine C source code with Visual Basic 6?

    Yes and no
    No you can't combine the code
    Yes you can create a dll and use it in your VB project.

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Is possible to combine C source code with Visual Basic 6?

    Wouldn't that be great! If the C code was written as, and compiled into, a DLL, then it is possible. But raw source code from another language needs to be converted to VB

    Ah, DM beat me to it
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Oct 2016
    Posts
    89

    Re: Is possible to combine C source code with Visual Basic 6?

    Ok, how to create DLL for C sources?
    Is Visual C++ backward compatible with C?
    How to create DLL? Even, how to call DLL?
    Application in C has no one parameter - after start searches for file in same directory as app and process it...

    Can you help?

    Miro

  5. #5
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,958

    Re: Is possible to combine C source code with Visual Basic 6?

    If the C code behaves in that way then converting it to a DLL could be a lot of work, especially if this isn't something you have done before. Depending on the complexity of the C code it might be possible to rewrite it in VB.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Oct 2016
    Posts
    89

    Re: Is possible to combine C source code with Visual Basic 6?

    It is very simple code - in less than 100 lines. Sources are 5 and else 3.
    These codes I tried to convert by converter - it failed in some parts - so I'm not able to do it...

    It is simple tool to render images for Commodore 128 VDC chip - 5 and 3 sources are for 8 modes totally.

    Miro

  7. #7
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: Is possible to combine C source code with Visual Basic 6?

    Sounds like you could just compile the C code into an exe and shell to it from your vb program

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Oct 2016
    Posts
    89

    Re: Is possible to combine C source code with Visual Basic 6?

    Yes, it is alternative, but problem is that it outputs to console during rendering - outputs curent processing column number.

    Miro

  9. #9
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,598

    Re: Is possible to combine C source code with Visual Basic 6?

    Where do you want to output it?
    You could just run the code in a cmd window and redirect the output to a file then read the file into a VB program if needed.
    C:\Users\passel>Ccode.exe > VDCchipImage.dat

    C:\Users\passel>

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Oct 2016
    Posts
    89

    Re: Is possible to combine C source code with Visual Basic 6?

    For test I tried to use it by shortcut:
    cmd /c render.exe > output.txt
    and set window minimized.
    Process was indicating in taskbar and output to file was empty, when I restore window I see progress...
    Only one problem is here - how to hide application indication in tasksbar?
    Not yet applied in VB.
    Miro

  11. #11
    Hyperactive Member
    Join Date
    Aug 2017
    Posts
    380

    Re: Is possible to combine C source code with Visual Basic 6?

    You may want to try the abandoned ThunderVB project. Download it either from PSC or SourceForge.


    Name:  PIC200582516544864.gif
Views: 2997
Size:  153.6 KB

  12. #12
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,229

    Re: Is possible to combine C source code with Visual Basic 6?

    If you just post your source here, there are a bunch of us fluent in C and many other languages.
    I just posted some source in the C/C++ thread on how to deal with a ParamArray from C, but it sounds like it would be sooo much easier just converting it by hand.

    and yes VC can compile C.

    http://www.vbforums.com/showthread.p...n-C-export-DLL

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Oct 2016
    Posts
    89

    Re: Is possible to combine C source code with Visual Basic 6?

    I know that C source code is published under GNU GPL, but I know author personally and must to ask if can I publish it here.

    Miro

  14. #14
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,229

    Re: Is possible to combine C source code with Visual Basic 6?

    Quote Originally Posted by MIRKOSOFT View Post
    I know that C source code is published under GNU GPL, but I know author personally and must to ask if can I publish it here.

    Miro
    you could just post a link to it?

  15. #15
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    868

    Re: Is possible to combine C source code with Visual Basic 6?

    Vic

    Somewhat off-topic, but how did you do that?
    I've modified your string by adding "x" so it just appears here as text ..

    [xCENTER][xATTACH=xCONFIG]150621[x/ATTACH][x/CENTER]

    Could you explain
    Is it a video?

    Spoo

  16. #16
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,229

    Re: Is possible to combine C source code with Visual Basic 6?

    Quote Originally Posted by Spooman View Post
    Vic

    Somewhat off-topic, but how did you do that?
    I've modified your string by adding "x" so it just appears here as text ..

    [xCENTER][xATTACH=xCONFIG]150621[x/ATTACH][x/CENTER]

    Could you explain
    Is it a video?

    Spoo
    are you asking how he created the animated GIF ? He just lifted it from whoever made the PSC post.

  17. #17
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    928

    Re: Is possible to combine C source code with Visual Basic 6?

    I used Visual C++ same generation as VB6, compile some DLL in it, and called it from VB, it is just the _stdcall , the only one thing is to export the functions the dll must provide to VB.

    Then place it next to the APP EXE, and just use it.

    The easier is using all parameters in 32bits, so the signature must be long long long...., include if in the VB you uses it as boolean, or integer, it is in real LONGs, include strings, strings it is just a LONG pointer to the string header, then from the header you must read the pointer to the string itself, ooooor strptr to pass directly the pointer to the string. Then it is the things C++ likes null terminated strings, or you do special C code to read the LENGTH at [StrPtrr-4] IIRC

    Include the DLL will always works as a function, include if it is VOID, it is structured as a function, the Return value is passed in EAX.

    that is the _stdcall. All is passed by stack, and locals are allocated in stack, x86 is perfectly designed to do that, but you don't see that fact in C++, the language abstracts that well. You will see those facts if coding in ASM, which also I did. As an old asm guy.

  18. #18

    Thread Starter
    Lively Member
    Join Date
    Oct 2016
    Posts
    89

    Re: Is possible to combine C source code with Visual Basic 6?

    Ok, I do all possible to contact creator of code 'cause friend usedit from other man.
    I'll reply when I will know if is possible to publish it.
    Miro

  19. #19
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    868

    Re: Is possible to combine C source code with Visual Basic 6?

    Quote Originally Posted by DEXWERX View Post
    are you asking how he created the animated GIF ? He just lifted it from whoever made the PSC post.
    OK, thanks
    I've never used animated GIF before.

    Spoo

  20. #20

    Thread Starter
    Lively Member
    Join Date
    Oct 2016
    Posts
    89

    Re: Is possible to combine C source code with Visual Basic 6?

    Ok, I have agreement to publish sources in C.
    Have I create code parts in text or attach them to post?

    Miro

  21. #21
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,909

    Re: Is possible to combine C source code with Visual Basic 6?

    Hmmm, through the years, I've been involved with a couple of different applications that were written in C. However, these were stand-alone applications, and we didn't compile anything to a DLL. I must admit that I've had very little to do with C++.

    Another thing I was a bit more recently involved with was dealing with a few Fortran algorithms. Using the Microsoft Fortran Compiler, I was able to create a standard callable DLL that's called from VB6. And I don't remember this being a great deal of work.

    With admittedly somewhat limited knowledge, it's a bit confusing to me why one couldn't just find a C compiler that would create a standard DLL that could be called from VB6. I'm guessing that an ActiveX DLL might be more work. However, if all we're after is certain algorithms, it seems that a standard DLL could get it done.

    Best Regards,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  22. #22

    Thread Starter
    Lively Member
    Join Date
    Oct 2016
    Posts
    89

    Re: Is possible to combine C source code with Visual Basic 6?

    So, I attached files in ZIP.

    I hope that anybody has bit of time to help me by converting it to Visual Basic.
    I tried converter but some parts marked as error and in VB source was original code line.

    About files:
    ****************
    VDC file lines
    ---------------------
    hfli_quant.c 231
    i3vdc_quant.c 217
    image.c 211
    image.h 38
    ivdc_quant.c 226
    matrix.h 24
    vdc_quant.c 228
    ================
    VGA file lines
    ---------------------
    hfli_quant.c 231
    image.c 211
    image.h 38
    matrix.h 24
    tfli_quant.c 231
    ****************
    some files looking same, but I'm not able to be sure 'cause don't know C.

    Thank you all for at least reading it.
    Miro

    C.zip

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