locked
Convert C++ to Vb.net RRS feed

  • Question

  • User-1356300786 posted

    hi all

    can help me?

    i will convert c++ to vb.net

    this c++

    for(n1;n1<=n2;n1++)
    {
    if(n1%2==1)
    {
    Sleep(10);
    sprintf(n3,"%i",n1);
    x=strlen(n3);
    switch(x)
    {
    case 1:
    printf("|| ");
    printf(n3);
    printf(" || ");
    printf("%d",n1);
    printf(" ||\n");
    ulang++;
    tdk_ulang++;
    break;



    and this my vb.net

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    ulang = 0
    tdk_ulang = 0
    n1 = TextBox1.Text
    n2 = TextBox2.Text
    For i = n1 To n1 < n2 Step 1
    If n1 Mod 2 = 1 Then
    Dim n3 As Char = Convert.ToChar(n1)
    x = Str(n3)
    Select Case x
    Case 1
    ListBox1.Items.Add(n2)
    ListBox2.Items.Add(n1)
    ulang += 1
    tdk_ulang += 1
    n1 += 1
    
    End Select
    End If
    Next
    
    End Sub



    not found error in vb.net and running success

    but i can't see output in listbox

    please help me :D


    thx before

    Thursday, April 30, 2015 2:14 AM

All replies

  • User-1716253493 posted

    Try this

            Dim ulang As Integer = 0
            Dim tdk_ulang As Integer = 0
            Dim n1 As Integer = TextBox1.Text
            Dim n2 As Integer = TextBox2.Text
            For i As Integer = n1 To n2
                If n1 Mod 2 = 1 Then
                    Dim n3 As Char = Convert.ToChar(n1)
                    Dim x As Integer = Str(n3)
                    Select Case x
                        Case 1
                            ListBox1.Items.Add(n2)
                            ListBox2.Items.Add(n1)
                            ulang += 1
                            tdk_ulang += 1
        
                    End Select
                End If
            Next

    Thursday, April 30, 2015 2:36 AM
  • User-1356300786 posted

    Try this

            Dim ulang As Integer = 0
            Dim tdk_ulang As Integer = 0
            Dim n1 As Integer = TextBox1.Text
            Dim n2 As Integer = TextBox2.Text
            For i As Integer = n1 To n2
                If n1 Mod 2 = 1 Then
                    Dim n3 As Char = Convert.ToChar(n1)
                    Dim x As Integer = Str(n3)
                    Select Case x
                        Case 1
                            ListBox1.Items.Add(n2)
                            ListBox2.Items.Add(n1)
                            ulang += 1
                            tdk_ulang += 1
        
                    End Select
                End If
            Next

    hmm running success

    but stuck in 

    Str(n3)

    str in c++ strlen

    in vb not work?

    Thursday, April 30, 2015 2:58 AM
  • User397347636 posted
    Imports Microsoft.VisualBasic
    Imports System
    
    Dim n1 As Integer
    Do While n1 <= n2
    	If n1 Mod 2 = 1 Then
    		System.Threading.Thread.Sleep(10)
    		n3 = String.Format("{0:D}", n1)
    		x = n3.Length
    		Select Case x
    			Case 1
    				Console.Write("|| ")
    				Console.Write(n3)
    				Console.Write(" || ")
    				Console.Write("{0:D}",n1)
    				Console.Write(" ||" & ControlChars.Lf)
    				ulang += 1
    				tdk_ulang += 1
    		End Select
    	End If
    	n1 += 1
    Loop

    Thursday, April 30, 2015 9:53 AM
  • User-1078840699 posted

    Install this http://www.tangiblesoftwaresolutions.com/Free_Editions.html converter c++ to VB.net

    Also, read this article https://social.msdn.microsoft.com/Forums/en-US/7c7fea02-c736-4367-ad4d-818536d4f1d2/convert-c-to-vb?forum=vblanguage

    Thursday, April 30, 2015 11:18 AM
  • User-1356300786 posted

    thanks  i will try

    Thursday, April 30, 2015 2:31 PM