C语言转换为VB.NETOption Explicit On
Option Strict On
Imports System
Module Program
Sub Main()
Dim y,m,t As Integer
begin:
' 输入数据时一行一个
y=CInt(Console.ReadLine())
m=CInt(Console.ReadLine())
t=CInt(Console.ReadLine())
If y
200 Then
Console.WriteLine("ERROR")
goto begin
End If
pr(y,m,t)
Console.Write("Press any key to continue . . . ")
Console.ReadKey(True)
End Sub
Function pr(y As Integer,m As Integer,t As Integer) As Integer
Dim ye,[Me],i As Integer
ye=CInt((m t-2)/12 y)
[Me]=(m t-2) Mod 12 1
End If
End Function
Function mday(y As Integer,m As Integer) As Integer
Dim day As Integer()={0,31,28,31,30,31,30,31,31,30,31,30,31}
Dim ad As I
下面的VB6.0编写的代码怎么转为VB.netDim file1 As FileStream
filename = "c:\temp\MyTest.txt"
Dim GetData(4) As Byte, s(4) As Char
file1 = System.IO.File.OpenRead(filename)
Dim CMGs As Long
Dim DPBo As Long
Dim i As Integer = 0, j As Integer
While file1.Read(GetData, 0, 5)0
i = i1
For j = 0 To 4
s(j) = ChrW(GetData(j))
Next
If s = "CMG=""" Then CMGs = i
If s = "[Host" Then DPBo = i - 2 : Exit While
End While
主要是vb.net取消了定长字符串, 所以用字节数组读入, 还得转成字符数组来比较.
C#代码转vb.netProtected OverridesSub WndProc(ByRef m As Message)
Select Case m.Msg
Case 0x46
Dim rect As Rectangle =Screen.GetWorkingArea(Me)
Dim winPos As WINDOWPOS = CType(m.GetLParam(Type.GetType(WINDOWPOS)), WINDOWPOS)
If winPos.xwinPos.cxrect.Right Then
winPos.x = rect.Right - winPos.cx
End If
If winPos.ywinPos.cyrect.Bottom Then
winPos.y = rect.Bottom - winPos.cy
End If
If winPos.xrect.Top Then
winPos.x = rect.Top
End If
If winPos.yrect.Left Then
winPos.y = rect.Left
End If
Marshal.StructureToPtr(winPos, m.LParam, False)
MyBase.WndProc( m)
Exit Sub
Case Else
MyBase.WndProc( m)
Exit Sub
End Select
End Sub
StructLayout(LayoutKind.Sequential) _
Friend Structure WINDOWPOS
Friend hWnd As IntPtr
Friend hWndInsertAfter As IntPtr
Friend x As Integer
Friend y As Integer
Friend cx As Integer
Friend cy As Integer
Friend flags As Integer
End Structure
vb的回调函数转为vb.NET先声明一个委托:
Public Delegate Function EnumChildProc(hwnd As Integer, iParam As Integer) As Integer
然后才能使用回调函数 , 回调函数的参数要和委托完全一致 。
然后那个 API 函数需要这样声明:
Declare Function EnumChildWindows Lib "user32" (hWndParent As Integer, lpEnumFunc As EnumChildProc, lParam As Integer) As Integer
C# to vb.net 代码转换System.Runtime.InteropServices.DllImport("user32.dll") _
Public Shared Function SetWindowLong(hWnd As IntPtr, nIndex As Integer, wndproc As Integer) As Integer
End Function
System.Runtime.InteropServices.DllImport("user32.dll") _
Public Shared Function GetWindowLong(hWnd As IntPtr, nIndex As Integer) As Integer
End Function
Public Const GWL_STYLE As Integer = -16
Public Const WS_DISABLED As Integer = H8000000
Public Shared Sub SetControlEnabled(c As Control, enabled As Boolean)
If enabled Then
SetWindowLong(c.Handle, GWL_STYLE, (Not WS_DISABLED) And GetWindowLong(c.Handle, GWL_STYLE))
Else
SetWindowLong(c.Handle, GWL_STYLE, WS_DISABLEDGetWindowLong(c.Handle, GWL_STYLE))
End If
End Sub
授人以渔转vb.net:
这个网站超牛逼
【包含转vb.net的词条】关于转vb.net和的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。
推荐阅读
- 快手怎么开预测直播的,快手怎么开预测直播的人
- 如何选择新媒体专业考研,新媒体方向考研
- oracle数据库随机产生一个6位整数,oracle数据库随机产生一个6位整数
- 最美网红遇害直播视频,网红被杀事件
- c语言延迟1ms的函数 c语言延迟程序
- 苹果cms7asp,苹果13
- 手机模拟驾驶游戏不收费,手机模拟驾驶游戏大全
- 直播互动工具视频,直播互动软件有哪些
- python怎么生成函数 python 生成