现在的位置: 首页 > 综合 > 正文

VB&VB.NET速查表

2012年11月30日 ⁄ 综合 ⁄ 共 5650字 ⁄ 字号 评论关闭

事件

VB6: DoEvents

VB.NET: System.Windows.Forms.Application.DoEvents()


颜色
VB6: Command1.BackColor  =  vbRed

VB.NET:

Command1.BackColor  =  System.Drawing.Color.Red    
Command1.BackColor  =  System.Drawing.Color.FromARGB(&H80C0FF)


组合框中的列表:

VB6: ComboBox1.AddItem  "one"

VB.NET: ComboBox1.Items.Add("one")


颜色:
VB6: Command1.BackColor  =  &H80C0FF

VB.NET: Command1.BackColor  = System.Drawing.ColorTranslator.FromOle(&H80C0FF&)


窗体:

VB6:Form1.Caption  =  "Sample"

VB.NET: Form1.DefInstance.Text  =  "Sample" 


VB6: Form1.Top 

VB.NET: Form1.DefInstance.Top


消息框:
VB: MsgBox  "message",  vbInformation,  "title"

VB.NET: MsgBox("message",  MsgBoxStyle.Information,  "title")


窗体高度:
VB6: Form1.Height  =  3500

VB.NET: Form1.DefInstance.Height  =  VB6.TwipsToPixelsY(3500)


对象赋值:
VB6: Set  MyObject  =  Command1

VB.NET: MyObject  =  Command1


控件焦点:

VB6: Text1.SetFocus      

VB.NET:  Text1.Focus()      


提示:

VB6: Command1.ToolTipText  =  "click  me"      

VB.NET:  ToolTip1.SetToolTip(Command1,  "click  me")


     

窗体声明:

VB6:Dim  objAbout  As  AboutForm      

VB.NET:  Dim  objAbout  As  Pharfruminsain_AboutForm_v1r0.AboutForm    


 

取程序路径

VB6: sPath  =  App.Path      

VB.NTE:  sPath  =  Application.StartupPath  


VB6: Private  Sub  Form_Unload(Cancel  As  Integer)      

VB.NET:  Private  Sub  Form1_Closed(....)  Handles  MyBase.Closed      


VB6: List1.RemoveItem  (0)      

VB.NET:  ListBox1.Items.Remove(0)      


VB.NET: Dim  arOne(10)  As  String      

VB6:  Dim  arOne  As  New  ArrayList(10)      


VB6: Print  #1,  "sample  text"      

VB.NET:  PrintLine(1,  "sample  text")      


VB6: Open  "c:\myfile.txt"  For  Input  As  #1      

VB.NET:  FileOpen(1,  "c:\myfile.txt",  OpenMode.Input)      


VB6: Line  Input  #1,  sTemp      

VB.NET:   sTemp  =  LineInput(1)      


VB6:  
       s=App.Comments  
VB.Net:  
       Imports  System.Diagnostics  
       Imports  System.Reflection  
       s=FileVersionInfo.GetVersionInfo([Assembly].GetExecutingAssembly.Location).Comments  
 


VB6:  
       s=App.CompanyName  
VB.Net:  
       Imports  System.Diagnostics  
       Imports  System.Reflection  
       s=FileVersionInfo.GetVersionInfo([Assembly].GetExecutingAssembly.Location).CompanyName)  
 


VB6:  
       s=App.EXEName  
VB.Net:  
       Imports  System.Reflection  
       With  New  System.IO.FileInfo([Assembly].GetExecutingAssembly.Location)  
           s=.Name.Substring(0,  .Name.Length  -  .Extension.Length)  
       End  With  
   or  
       s=System.AppDomain.CurrentDomain.FriendlyName  
   Note:  this  includes  the  extension  which  would  need  to  be  parsed.  
 


VB6:  
       s=App.FileDescription  
VB.Net:  
       Imports  System.Diagnostics  
       Imports  System.Reflection  
       s=FileVersionInfo.GetVersionInfo([Assembly].GetExecutingAssembly.Location).FileDescription)  

 
VB6:  
       App.HelpFile  
VB.Net:  
       No  direct  replacement  
 


VB6:  
       i=App.hInstance  
VB.Net:  
       Imports  System.Runtime.InteropServices  
       i=Marshal.GetHINSTANCE([Assembly].GetExecutingAssembly.GetModules()(0)).ToInt32  
 


VB6:  
       s=App.LegalCopyright  
VB.Net:  
       Imports  System.Diagnostics  
       Imports  System.Reflection  
       s=FileVersionInfo.GetVersionInfo([Assembly].GetExecutingAssembly.Location).LegalCopyright)  
 


VB6:  
       s=App.LegalTrademarks  
VB.Net:  
       Imports  System.Diagnostics  
       Imports  System.Reflection  
       s=FileVersionInfo.GetVersionInfo([Assembly].GetExecutingAssembly.Location).LegalTrademarks)  
 

VB6:  
       App.LogMode  
       App.LogPath  
VB.Net:  
       No  direct  replacement;  see  the  EventLog  object  
 


VB6:  
       i=App.Major  
VB.Net:  
       Imports  System.Diagnostics  
       Imports  System.Reflection  
       i=FileVersionInfo.GetVersionInfo([Assembly].GetExecutingAssembly.Location).FileMajorPart)  
 


VB6:  
       i=App.Minor  
VB.Net:  
       Imports  System.Diagnostics  
       Imports  System.Reflection  
       i=FileVersionInfo.GetVersionInfo([Assembly].GetExecutingAssembly.Location).FileMinorPart)  
 


VB6:  
       App.NonModalAllowed  
VB.Net:  
       No  replacement  
 


VB6:  
       App.OleRequestPendingMsgText  
       App.OleRequestPendingMsgTitle  
       App.OleRequestPendingTimeout  
       App.OleServerBusyMsgText  
       App.OleServerBusyMsgTitle  
       App.OleServerBusyRaiseError  
       App.OleServerBusyTimeout  
VB.Net:  
       No  replacement;  OLE  automation  not  supported  
 


VB6:  
       s=App.Path  
VB.Net:  
       s=System.Windows.Forms.Application.StartupPath  
   or  
       Imports  System.Reflection  
               With  New  System.IO.FileInfo([Assembly].GetExecutingAssembly.Location)  
                   s  =  .FullName.Substring(0,  .FullName.Length  -  .Name.Length  -  1)  
               End  With  
Note:  this  will  return  the  path  with  no  trailing  backslash  even  if  the  application  is  in  the  root  directory.  The  VB  6.0  App.Path  method  return  included  the  trailing  backslash  when  the  executable  was  in  a  root  directory.  
 


VB6:  
       b=App.PrevInstance  
VB.Net:  
       Imports  System.Diagnostics  
       b=(UBound(Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName))  >  0)  

 
VB6:  
       s=App.ProductName  
VB.Net:  
       Imports  System.Diagnostics  
       Imports  System.Reflection  
       s=FileVersionInfo.GetVersionInfo([Assembly].GetExecutingAssembly.Location).ProductName)  
 


VB6:  
       App.RetainedProject  
VB.Net:  
       No  replacement;  state  not  supported  
 


VB6:  
       i=App.Revision  
VB.Net:  
       Imports  System.Diagnostics  
       Imports  System.Reflection  
       i=FileVersionInfo.GetVersionInfo([Assembly].GetExecutingAssembly.Location).FileBuildPart)  
   and/or:  
       i=FileVersionInfo.GetVersionInfo([Assembly].GetExecutingAssembly.Location).FilePrivatePart)  
 


VB6:  
       App.StartMode  
VB.Net:  
       No  direct  replacement  
 


VB6:  
       App.TaskVisible  
VB.Net:  
       No  direct  replacement  
 

VB6:  
       App.ThreadID  
VB.Net:  
       No  direct  replacement;  see  the  System.Threading.Thread  object  
 


VB6:  
       App.Title  
VB.Net:  
The  Text  (caption)  of  the  top-level  form.  If  there  are  no  forms  then  the  process  does  not  appear  in  Task  Manager.  
 


VB6:  
       App.UnattendedApp  
VB.Net:  
       No  direct  replacement  
 


Methods:  
 
VB6:  
       App.StartLogging  
       App.LogEvent  
VB.Net:  
       No  direct  replacement;  see  the  EventLog  object  

 

抱歉!评论已关闭.