Attention: We are retiring the ASP.NET Community Blogs. Learn more >

19 Comments

  • Private Sub SortDropDown(ByVal dd As DropDownList)

    Dim ar As ListItem()

    Dim i As Long = 0

    For Each li As ListItem In dd.Items

    ReDim Preserve ar(i)

    ar(i) = li

    i += 1

    Next

    Dim ar1 As Array = ar



    ar1.Sort(ar1, New ListItemComparer)

    dd.Items.Clear()

    dd.Items.AddRange(ar1)

    End Sub

    Private Class ListItemComparer _

    Implements IComparer



    Public Function Compare(ByVal x As Object, _

    ByVal y As Object) As Integer _

    Implements System.Collections.IComparer.Compare

    Dim a As ListItem = x

    Dim b As ListItem = y

    Dim c As New CaseInsensitiveComparer

    Return c.Compare(a.Text, b.Text)

    End Function

    End Class

  • You want this converted? After removing the extraneous line continuation in the ListItemComparer class header (this won't compile in VB.NET), and running it through Instant C#, I get:



    private void SortDropDown(DropDownList dd)

    {

    ListItem[] ar;

    long i = 0;

    foreach (ListItem li in dd.Items)

    {

    //INSTANT C# NOTE: The following 4 lines reproduce what 'ReDim Preserve' does behind the scenes in VB.NET:

    //ORIGINAL LINE: ReDim Preserve ar(i)

    ListItem[] Temp1 = new ListItem[i + 1];

    if (ar != null)

    System.Array.Copy(ar, Temp1, ar.Length);

    ar = Temp1;

    ar[i] = li;

    i += 1;

    }

    Array ar1 = ar;



    ar1.Sort(ar1, new ListItemComparer());

    dd.Items.Clear();

    dd.Items.AddRange(ar1);

    }

    private class ListItemComparer : IComparer



    {

    //INSTANT C# NOTE: This method implements an interface method

    //ORIGINAL LINE: Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare

    public int Compare(object x, object y)

    {

    ListItem a = x;

    ListItem b = y;

    CaseInsensitiveComparer c = new CaseInsensitiveComparer();

    return c.Compare(a.Text, b.Text);

    }

    }

  • I used the Babelfisken converter to port the Kernel32 dll apis from VB.NET to C# for the calls at the above url. - A few problems I found were that it does not preserve the actual Library called (in my case kernel32.dll), but replaces it with "GAIS" for some reason. Also, structs missed the opening {. Having said that, it's the best available save using the Anakrino Decompiler to convert the MSIL from VB.NET to C#.



  • Private Function GetValue(ByVal DOB As DateTime, ByVal DateFor As DateTime, ByVal CycleLength As Integer) As Integer

    Dim intDaysAlive, intValue As Integer

    intDaysAlive = DateDiff(DateInterval.Day, DOB, DateFor)

    intValue = CInt(System.Math.Sin(DegToRad(intDaysAlive * (360 / CycleLength))) * 100)

    Return intValue

    End Function



    Public Function PhysicalValue(ByVal DOB As String, ByVal DateFor As String) As String

    Return CStr(GetValue(CDate(DOB), CDate(DateFor), 23))

    End Function



    Public Function EmotionalValue(ByVal DOB As String, ByVal DateFor As String) As String

    Return CStr(GetValue(CDate(DOB), CDate(DateFor), 28))

    End Function



    Public Function IntellectualValue(ByVal DOB As String, ByVal DateFor As String) As String

    Return CStr(GetValue(CDate(DOB), CDate(DateFor), 33))

    End Function

  • Good,But How can i join with you

  • how to convert---
    unsigned char temp1,temp2;
    int cnt,si;
    temp1 = rs_232_temp;
    cnt = 0;
    for (si=0;si> 1;
    }
    temp1 = cnt % 2;
    if (temp1 == 1)
    rs_232_temp = rs_232_temp | 0x80;
    else
    rs_232_temp = rs_232_temp & 0x7f;
    serial_send(rs_232_temp);


    -- to visual basic

  • hi plz send me on my mail (b_rocky02@hotmail.com)a link to download a software how convert VB6 to c#
    thanks in advance

  • GHJGHJGHJGHJGHJGHJGHJGHJ

  • Option Explicit

    Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
    Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByRef lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long


    Public Function KnightOnline_Hwnd() As Long
    Dim KnightOnline_Client As Long
    KnightOnline_Client = FindWindow(vbNullString, "KnightOnline_Client")
    KnightOnline_Hwnd = KnightOnline_Client
    End Function

    Function ReadMemory(ByVal Address As Long) As String
    Dim PID As Long, PHandle As Long
    If KnightOnline_Hwnd = 0 Then Exit Function
    GetWindowThreadProcessId KnightOnline_Hwnd, PID
    PHandle = OpenProcess(&H10, False, PID)
    If PHandle = 0 Then Exit Function
    ReadMemory = Space$(12)
    ReadProcessMemory PHandle, Address, ByVal StrPtr(ReadMemory), 24, ByVal 0&
    CloseHandle PHandle
    End Function

    Public Function ReadMemorys(Address As Long) As Long
    Dim PID As Long, PHandle As Long
    If KnightOnline_Hwnd = 0 Then Exit Function
    GetWindowThreadProcessId KnightOnline_Hwnd, PID
    PHandle = OpenProcess(&H10, False, PID)
    If PHandle = 0 Then Exit Function
    ReadProcessMemory PHandle, Address, ReadMemorys, 4, 0&
    CloseHandle PHandle
    End Function

    Function ReadNewAdress(ByVal Pointer As Long, ByVal Offset As Long)
    ReadNewAdress = ReadMemorys(Pointer) + Offset
    End Function

    add 3 text ..
    and 1 button .

    Private Sub Command1_Click()
    Text1 "HP: " & ReadMemorys(ReadNewAdress(&HCEBB4C, &H448))
    Text2 "MP: " & ReadMemorys(ReadNewAdress(&HCEBB4C, &H44C))
    Text3 "Nick: " & ReadMemory(&HCEA538)
    End Sub









    Please convert it to C#

  • Private Sub cmbstaffid_Click()
    If rstaff.BOF = False And rstaff.EOF = False Then
    rstaff.MoveFirst
    Do While Not rstaff.EOF = True
    If Val(cmbstaffid.Text) = rstaff.Fields("StaffID").Value Then
    txtename.Text = rstaff.Fields("Name").Value
    Call staffdetails
    Exit Sub
    End If
    rstaff.MoveNext
    cmddelete.Enabled = True
    Loop
    End If
    End Sub

  • Program code conversion from vb6 to c #

  • ki doos dareh mano bokoneh? sharj migiram web midam! mina_pati
    kos
    kir
    webcam


    i love u :)

  • Public Class Form1

    Private Const MF_BYPOSITION = &H400
    Private Const MF_REMOVE = &H1000
    Private Const MF_DISABLED = &H2

    Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As IntPtr, ByVal nPosition As Integer, ByVal wFlags As Long) As IntPtr
    Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As IntPtr, ByVal bRevert As Boolean) As IntPtr
    Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As IntPtr) As Integer
    Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As IntPtr) As Boolean

    Public Sub DisableCloseButton(ByVal hwnd As IntPtr)
    Dim hMenu As IntPtr
    Dim menuItemCount As Integer

    hMenu = GetSystemMenu(hwnd, False)
    menuItemCount = GetMenuItemCount(hMenu)
    Call RemoveMenu(hMenu, menuItemCount - 1, MF_DISABLED Or MF_BYPOSITION)
    Call RemoveMenu(hMenu, menuItemCount - 2, MF_DISABLED Or MF_BYPOSITION)
    Call DrawMenuBar(hwnd)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    DisableCloseButton(Me.Handle)
    End Sub
    End Class

  • Function shamsidate(miladydate as date)as string
    Dim shamsiyear as integer
    Dim shamsimonth as integer
    Dim shamsiday as integer
    Dim miladyyear as integer
    Dim datedifference as integer
    Dim firstdayofyear as string
    Dim strday as string
    If hour(miladydate)>11 then
    Miladydate=miladydate-1
    End if
    If (year(miladydate)>1995) then
    Miladyyear=1997+((year(miladydate)-1996)\4)*4
    Else
    Miladyyear=1997
    End if
    If (isdate("1999/20/12")=1) then
    Firstdayofyear="/20/03"
    Else
    Firstdayofyear="/03/20"
    End if
    If miladydate=cdate((ltrim(str(miladyyear))+firstdayofyear)) then
    Shamsiyear=year(miladydate)-1997+1375
    Shamsimonth=12
    Shamsiday=30
    Strmonth=ltrim(str(shamsimonth))
    If (shamsimonth<10)then
    Strmonth="0"+strmonth
    End if
    Strday=ltrim(str(shamsiday))
    If(shamsiday=cdate(ltrim(str (miladyyear-1))+(firstdayofyear)and miladydate<cdate(ltrim(str(miladyyear))+(firstdayofyear) then
    miladydate=miladydate+1
    end if
    miladyyear=year(miladydate)
    if month(miladydate)<=2 or (month(miladydate)=3 and (day(miladydate)<21)then
    miladyyear=miladyyear-1
    end if
    shamsiyear=miladyyear-621
    datedifference=cint(miladydate –cdate((ltrim(str(miladyyear))+firstdayofyear)))
    if (datedifference<187)then
    shamsimonth=((datedifference-1)\31)+1
    shamsiday=datedifference-(shamsimonth-1)*31
    else
    shamsi month=((datedifference-187)\30)+7
    shamsiday=datedifference-(shamsimonth-7)*30-186
    end if
    strmonth=ltrim(str(shamsimonth))
    if (shamsimonth<10)then
    strmonth="0"+strmonth
    end if
    strday=ltrim(str(shamsiday))
    if (shamsiday<10)then
    strday="0"+strday
    end if
    shamsidate=rtrim(ltrim(str(shamsiyear)))+rtrim(ltrim(strmonth))+rtrim(ltrim(strday))
    end function

  • converted vb to c#

  • if (File.Exists(@"D:\\POUYA SYSTEM\\Bank" + "\\DISKETTEBIME_POUYA_Data.MDF"))
    {
    SqlConnection scon = new SqlConnection("Integrated Security=true;initial catalog=Master;Data source=.");
    scon.Open();

    string command1 = "if not exists (select name from dbo.sysdatabases where name='DISKETTEBIME_POUYA') EXEC sp_attach_db 'DISKETTEBIME_POUYA','" +
    @"D:\\POUYA SYSTEM\\Bank" + "\\DISKETTEBIME_POUYA_Data.MDF','" +
    @"D:\\POUYA SYSTEM\\Bank" + "\\DISKETTEBIME_POUYA_Log.LDF'";


    SqlCommand scom1 = new SqlCommand(command1, scon);

    scom1.ExecuteNonQuery();
    scon.Close();
    MessageBox.Show("ثبت گردید POUYA SYSTEM و با نام D اطلاعات شما با موفقیت در درایو ");

    }
    else MessageBox.Show("خطلا در وصل بانک اطلاعاتی ");
    }

  • VB6 and VB.NET to C# Converter

  • I required it so urgently if u have any websites plz send me

  • I need programe do for VB6 and VB.NET to C# Converter

Comments have been disabled for this content.