Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 1st, 2007, 4:37 PM   #1
mattireland
Hobbyist Programmer
 
mattireland's Avatar
 
Join Date: Jul 2007
Location: Wales, United Kingdom
Posts: 210
Rep Power: 2 mattireland is on a distinguished road
Send a message via MSN to mattireland Send a message via Skype™ to mattireland
VB.NET Code Conversion

Hi,

I've got a GUI in VB.NET and I was wondering if there was any way to easily convert it into a C++ console app?

Thanks,

Matt. I
__________________
Matt Ireland
http://www.mattireland.org
matt@mattireland.co.uk
mattireland is offline   Reply With Quote
Old Dec 1st, 2007, 4:42 PM   #2
mbd
Programmer
 
Join Date: Nov 2007
Posts: 86
Rep Power: 2 mbd is on a distinguished road
Re: VB.NET Code Conversion

how easy do you think it would be to convert to a vb.net console app?
mbd is offline   Reply With Quote
Old Dec 1st, 2007, 5:08 PM   #3
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 652
Rep Power: 4 Ancient Dragon is on a distinguished road
Re: VB.NET Code Conversion

>>if there was any way to easily convert it into a C++ console app?
No there is no easy way -- you will have to do it all manually. First chop out all the GUI stuff then add what's left over into a c++ program. But if you still want the c++ program to be GUI then it won't be a console program anymore will it ?
Ancient Dragon is offline   Reply With Quote
Old Dec 1st, 2007, 5:12 PM   #4
mattireland
Hobbyist Programmer
 
mattireland's Avatar
 
Join Date: Jul 2007
Location: Wales, United Kingdom
Posts: 210
Rep Power: 2 mattireland is on a distinguished road
Send a message via MSN to mattireland Send a message via Skype™ to mattireland
Re: VB.NET Code Conversion

I can easily make it into a VB.NET console app. Is there no software that will convert the VB.NET console app into a C++ console app. Thanks for the replies guys!
__________________
Matt Ireland
http://www.mattireland.org
matt@mattireland.co.uk
mattireland is offline   Reply With Quote
Old Dec 1st, 2007, 5:16 PM   #5
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 652
Rep Power: 4 Ancient Dragon is on a distinguished road
Re: VB.NET Code Conversion

Well, if you know both VB.NET and c++ why bother with making it VB console? I know of no software that will automate that conversion. Post one of the VB functions and let us see what we can do with it.
Ancient Dragon is offline   Reply With Quote
Old Dec 1st, 2007, 5:30 PM   #6
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 773
Rep Power: 3 Jimbo is on a distinguished road
Re: VB.NET Code Conversion

Just wondering, but any particular reason for the C++ requirement?
__________________
<insert disclaimer here>
<insert shameless plug for Visual Studio here>
Jimbo is offline   Reply With Quote
Old Dec 2nd, 2007, 5:30 AM   #7
mattireland
Hobbyist Programmer
 
mattireland's Avatar
 
Join Date: Jul 2007
Location: Wales, United Kingdom
Posts: 210
Rep Power: 2 mattireland is on a distinguished road
Send a message via MSN to mattireland Send a message via Skype™ to mattireland
Re: VB.NET Code Conversion

Nah, it's just for fun really. Here's the main VB.NET Code:

Imports System
Imports System.IO
Imports System.Reflection
Imports System.Text.RegularExpressions

Public Class FreqAnalysis


    Public Function CharCount(ByVal OrigString As String, _
    ByVal Chars As String, Optional ByVal CaseSensitive As Boolean = False) _
      As Long

        '**********************************************
        'PURPOSE: Returns Number of occurrences of a character or
        'or a character sequencence within a string

        'PARAMETERS:
        'OrigString: String to Search in
        'Chars: Character(s) to search for
        'CaseSensitive (Optional): Do a case sensitive search
        'Defaults to false

        'RETURNS:
        'Number of Occurrences of Chars in OrigString

        'EXAMPLES:
        'Debug.Print CharCount("FreeVBCode.com", "E") -- returns 3
        'Debug.Print CharCount("FreeVBCode.com", "E", True) -- returns 0
        'Debug.Print CharCount("FreeVBCode.com", "co") -- returns 2
        ''**********************************************

        Dim lLen As Long
        Dim lCharLen As Long
        Dim lAns As Long
        Dim sInput As String
        Dim sChar As String
        Dim lCtr As Long
        Dim lEndOfLoop As Long
        Dim bytCompareType As Byte

        sInput = OrigString
        If sInput = "" Then Exit Function
        lLen = Len(sInput)
        lCharLen = Len(Chars)
        lEndOfLoop = (lLen - lCharLen) + 1
        bytCompareType = IIf(CaseSensitive, vbBinaryCompare, _
           vbTextCompare)

        For lCtr = 1 To lEndOfLoop
            sChar = Mid(sInput, lCtr, lCharLen)
            If StrComp(sChar, Chars, bytCompareType) = 0 Then _
                lAns = lAns + 1
        Next

        CharCount = lAns

    End Function

    Private Sub anB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles anB.Click
        Dim analysise As String
        analysise = AnTxt.Text.ToUpper

        'Single letter analysis

        'Count
        Dim numA As Integer
        numA = CharCount(analysise, "A")
        Dim numB As Integer
        numB = CharCount(analysise, "B")
        Dim numC As Integer
        numC = CharCount(analysise, "C")
        Dim numD As Integer
        numD = CharCount(analysise, "D")
        Dim numE As Integer
        numE = CharCount(analysise, "E")
        Dim numF As Integer
        numF = CharCount(analysise, "F")
        Dim numG As Integer
        numG = CharCount(analysise, "G")
        Dim numH As Integer
        numH = CharCount(analysise, "H")
        Dim numI As Integer
        numI = CharCount(analysise, "I")
        Dim numJ As Integer
        numJ = CharCount(analysise, "J")
        Dim numK As Integer
        numK = CharCount(analysise, "K")
        Dim numL As Integer
        numL = CharCount(analysise, "L")
        Dim numM As Integer
        numM = CharCount(analysise, "M")
        Dim numN As Integer
        numN = CharCount(analysise, "N")
        Dim numO As Integer
        numO = CharCount(analysise, "O")
        Dim numP As Integer
        numP = CharCount(analysise, "P")
        Dim numQ As Integer
        numQ = CharCount(analysise, "Q")
        Dim numR As Integer
        numR = CharCount(analysise, "R")
        Dim numS As Integer
        numS = CharCount(analysise, "S")
        Dim numT As Integer
        numT = CharCount(analysise, "T")
        Dim numU As Integer
        numU = CharCount(analysise, "U")
        Dim numV As Integer
        numV = CharCount(analysise, "V")
        Dim numW As Integer
        numW = CharCount(analysise, "W")
        Dim numX As Integer
        numX = CharCount(analysise, "X")
        Dim numY As Integer
        numY = CharCount(analysise, "Y")
        Dim numZ As Integer
        numZ = CharCount(analysise, "Z")

        'Display Normal English Percentages

        NumEngA.Text = "8.4966"
        NumEngB.Text = "2.0720"
        NumEngC.Text = "4.5388"
        NumEngD.Text = "3.3844"
        NumEngE.Text = "11.1607"
        NumEngF.Text = "1.8121"
        NumEngG.Text = "2.4705"
        NumEngH.Text = "3.0034"
        NumEngI.Text = "7.5448"
        NumEngJ.Text = "0.1965"
        NumEngK.Text = "1.1016"
        NumEngL.Text = "5.4893"
        NumEngM.Text = "3.0129"
        NumEngN.Text = "6.6544"
        NumEngO.Text = "7.1635"
        NumEngP.Text = "3.1671"
        NumEngQ.Text = "0.1962"
        NumEngR.Text = "7.5809"
        NumEngS.Text = "5.7351"
        NumEngT.Text = "6.9509"
        NumEngU.Text = "3.6308"
        NumEngV.Text = "1.0074"
        NumEngW.Text = "1.2899"
        NumEngX.Text = "0.2902"
        NumEngY.Text = "1.7779"
        NumEngZ.Text = "0.2722"
        'e.t.c.

        'Display Ciphertext Numbers

        NumCiphA.Text = numA
        NumCiphB.Text = numB
        NumCiphC.Text = numC
        NumCiphD.Text = numD
        NumCiphE.Text = numE
        NumCiphF.Text = numF
        NumCiphG.Text = numG
        NumCiphH.Text = numH
        NumCiphI.Text = numI
        NumCiphJ.Text = numJ
        NumCiphK.Text = numK
        NumCiphL.Text = numL
        NumCiphM.Text = numM
        NumCiphN.Text = numN
        NumCiphO.Text = numO
        NumCiphP.Text = numP
        NumCiphQ.Text = numQ
        NumCiphR.Text = numR
        NumCiphS.Text = numS
        NumCiphT.Text = numT
        NumCIphU.Text = numU
        NumCiphV.Text = numV
        NumCiphW.Text = numW
        NumCiphX.Text = numX
        NumCiphY.Text = numY
        NumCiphZ.Text = numZ

        'Work Out Percentages

        Dim l As Integer = AnTxt.Text.Length
        Dim perA
        perA = numA / l * 100
        Dim perB
        perB = numB / l * 100
        Dim perC
        perC = numC / l * 100
        Dim perD
        perD = numD / l * 100
        Dim perE
        perE = numE / l * 100
        Dim perF
        perF = numF / l * 100
        Dim perG
        perG = numG / l * 100
        Dim perH
        perH = numH / l * 100
        Dim perI
        perI = numI / l * 100
        Dim perJ
        perJ = numJ / l * 100
        Dim perK
        perK = numK / l * 100
        Dim perL
        perL = numL / l * 100
        Dim perM
        perM = numM / l * 100
        Dim perN
        perN = numN / l * 100
        Dim perO
        perO = numO / l * 100
        Dim perP
        perP = numP / l * 100
        Dim perQ
        perQ = numQ / l * 100
        Dim perR
        perR = numR / l * 100
        Dim perS
        perS = numS / l * 100
        Dim perT
        perT = numT / l * 100
        Dim perU
        perU = numU / l * 100
        Dim perV
        perV = numV / l * 100
        Dim perW
        perW = numW / l * 100
        Dim perX
        perX = numX / l * 100
        Dim perY
        perY = numY / l * 100
        Dim perZ
        perZ = numZ / l * 100

        'Display Ciphertext Percentages

        PerCiphA.Text = perA
        PerCiphB.Text = perB
        PerCiphC.Text = perC
        PerCiphD.Text = perD
        PerCiphE.Text = perE
        PerCiphF.Text = perF
        PerCiphG.Text = perG
        PerCiphH.Text = perH
        PerCiphI.Text = perI
        PerCiphJ.Text = perJ
        PerCiphK.Text = perK
        PerCiphL.Text = perL
        PerCiphM.Text = perM
        PerCiphN.Text = perN
        PerCiphO.Text = perO
        PerCiphP.Text = perP
        PerCiphQ.Text = perQ
        PerCiphR.Text = perR
        PerCiphS.Text = perS
        PerCiphT.Text = perT
        PerCiphU.Text = perU
        PerCiphV.Text = perV
        PerCiphW.Text = perW
        PerCiphX.Text = perX
        PerCiphY.Text = perY
        PerCiphZ.Text = perZ


        'Pair letter analysis


        'Repeated letter analysis
    End Sub

    Private Sub Paste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Paste.Click
        AnTxt.Text = Clipboard.GetText
    End Sub

    Private Sub Copy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Copy.Click

    End Sub
End Class


I was trying to get this to work with an input and output text file in C++ but have so far had no luck Thanks very much for helping!

Jimbo - no real point - just an academic excercise I originally made it in VB.NET as part of a bigger application and I'm much better with VB.NET and VB 6.
__________________
Matt Ireland
http://www.mattireland.org
matt@mattireland.co.uk
mattireland is offline   Reply With Quote
Old Dec 2nd, 2007, 9:40 AM   #8
Ancient Dragon
PFO God In Training
 
Ancient Dragon's Avatar
 
Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 652
Rep Power: 4 Ancient Dragon is on a distinguished road
Re: VB.NET Code Conversion

CharCount is easy to code in c or c++, no need to use the VB code for that.

This is how I would code CharCount() function, the first part anyway.
#include <iostream>
#include <string>
#include <algorithm>

size_t CharCount(const char* line, char Ch, bool CaseSensitive = false)
{
     size_t count = 0;
     size_t i;
     std::string dup;
     dup = line;
     if(CaseSensitive == true)
     {
           std::transform(dup.begin(),dup.end(),dup.begin(), toupper);
     }
    // now count the letters
    for(i = 0; i < dup.size(); ++i)
    {
          if( dup[i] ==  Ch)
             ++count;
     }
     return count;

}

void anB_Click()
{
    size_t counts[26] = {0};
    int percentages[26] = {0};
    size_t len;
    char* string = "This is the string to be used";

    for(int i = 0; i < 26; i++)
         counts[i] = CharCount(string, i+'A');
    len = strlen(string);
    for(int i = 0; i < 26; i++)
        percentages[i] = (int) (((float)counts[i] / (float)len) * 100.0F);   

}

Last edited by Ancient Dragon; Dec 2nd, 2007 at 10:14 AM.
Ancient Dragon is offline   Reply With Quote
Old Dec 2nd, 2007, 1:00 PM   #9
mbd
Programmer
 
Join Date: Nov 2007
Posts: 86
Rep Power: 2 mbd is on a distinguished road
Re: VB.NET Code Conversion

anything that is .net only can be converted easily between vb.net, c#.net and even c++. check out http://www.tangiblesoftwaresolutions.com/
mbd is offline   Reply With Quote
Old Dec 2nd, 2007, 3:31 PM   #10
WaltP
Programmer
 
Join Date: Oct 2007
Posts: 39
Rep Power: 0 WaltP is on a distinguished road
Re: VB.NET Code Conversion

Quote:
Originally Posted by mbd View Post
anything that is .net only can be converted easily between vb.net, c#.net and even c++. check out http://www.tangiblesoftwaresolutions.com/
Where do you get that idea? You must work for Tangible.
WaltP is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Viewing VB's Automated code john Wesley Visual Basic .NET 3 Jun 8th, 2006 6:37 AM
FTP and return code fetching Serinth C 2 May 29th, 2006 12:05 AM
vb6 to vb.net bl00dninja Visual Basic .NET 2 Sep 24th, 2005 2:55 PM
Number conversion deathseeker25 C 34 Sep 3rd, 2005 1:07 PM
How do I call C++ code from a VB.NET app? uman C++ 2 Feb 9th, 2005 8:03 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:25 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC