In the work, you may encounter the need to migrate the code written in VB to VB. NET, there are a lot of details to deal. Fortunately, after so many years of Internet development, many questions have been answered on the Internet, so you can search for them to solve them. I have also encountered the migration from VB to VB. NET. Now I will summarize the problems encountered and their solutions or alternative methods to facilitate future users. First, let's take a look at this article converting VB6 to VB. NET at http://dotnet.sys-con.com/node/46335. Secondly, download and install Microsoft Visual Basic Power packs, so that after you use the Wizard to migrate the VB6 code to VB. NET, you can "eliminate" Many compilation errors. VB power packs 2.0 corresponds to vs2005, which is not found by myself. VB power packs 3.0 corresponds to vs2008,: http://download.microsoft.com/download/1/2/A/12AA9B28-4F67-42C3-9319-684E8AD6F0AE/VisualBasicPowerPacks3Setup.exe said VB power packs 10.0 has been released, interested readers please search by yourself. Then there are all kinds of trivial problems. One problem can be solved. Problem: newindex is not "system. windows. forms. listBox member Method 1: dim X as integerx = ListBox. items. add (rsdates. fields ("FD "). value) ListBox. selectedindex = x Method 2: ListBox. items. add (rsdates. fields ("FD "). value) ListBox. selectedindex = ListBox. items. count-1 problem: If app. previnstance then: IF process. getprocessesbyname (process. getcurrentprocess. processname ). length> 1 then problem: Unload () method: Theoretically speaking, VB. net has a garbage collection mechanism, so You don't need to log out of the object actively. You just need to comment out the object directly (without strict verification): You need to set "mscomctl, version = 10.0.20.4.0, culture = neutral, publickeytoken ...... Cause: the office control method is referenced: Install Visual Studio Tools for office in Vs, and install ". net programmable support more detailed information: http://saber5d.blog.163.com/blog/static/12799877820098164556798/ problem: picturebox. CLS () method: picturebox. refresh () Problem: datetime. datediff () method: dateandtime. datediff (): dynamically add panel dim X as integer x = statusbar in the status bar. panels. count statusbar. panels. add X, string1, string2 statusbar. panels. add x + 1, string1, string2 Upgrade Wizard to code Changed to statusbar. items. add (new system. windows. forms. toolstripstatuslabel (integer, string1, string2) method: manually change it to statusbar. items. add (new system. windows. forms. toolstripstatuslabel (string) statusbar. items. item (statusbar. items. count-1 ). TEXT = string: "paintpicture" is not "system. windows. forms. picturebox member. Method 1: dim G as graphics = picture1.creategraphics () g. drawimage (PIC, x, y) method. The image disappears every time the picturebox is re-painted. Method 2: Private blankbitmap as bitmap blankbitmap = new Bitmap (70*12, maxrow * 12) picture1.image = blankbitmap dim G as graphics G = graphics. fromimage (picture1.image) g. drawimage (PIC, x, y), the image will not disappear every time the picturebox is re-painted. Problem: lenb () method 1: Public Function lenb (byval ostring as string) as integer dim strarray () as byte dim strlen as integer dim myencoder as system. text. encoding = system. text. encoding. default strarray = myencoder. getbytes (ostring) strlen = strarray. length return strlen end Function Method 2: system. text. encoding. getencoding ("gb2312 "). getbytecount (strmsg): vb6.loadrespicture ("picturename", vb6.loadresconstants. resbitmap) method: me. backgroundimage = my.resources.bmp bcsstart problem: On Error *** recommended: Try to replace it with try catch problem: if the background color is set for a button, especially in the enter or leave event, from VB6 to VB.. net, if no button is set for the background color, the background color method will be automatically added: manually search the code, keyword "backgroundcolor", and then modify the problem one by one: the same font and font size, in VB6 and VB. there are minor differences in the space occupied on the net interface: Check all interfaces. problem: the tab page uses the ActiveX control XXX to solve: replace it. net tab: base64 encoding and decoding method: encoding dim X as byte () x = system. text. encoding. ASCII. getbytes (s) encrypt = convert. tobase64string (x) decodes dim X as byte () x = convert. frombase64string (s) decrypt = system. text. encoding. ASCII. getstring (x) Problem: a dialog box flashed through the method: transfer the code in form_activated to form_load, and comment out the form_activated problem: convert ICO to BMP vb6.imagetoipicturedisp (vb6.loadrespicture ("ICO", 1) method: My. resources. ICO ***. tobitmap () Problem: Form Center Method: Set the form attributes. Problem: isnull () method: isdbnull () problem when accessing the database: Data Report method: to replace it with Crystal Report, rdlc, and other report controls, you need to rewrite the Code. For other issues summarized by atai, refer to VB6 to VB. net2005 migration knowledge
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.