VB ×Ö½ÚÊý×éºÍ×Ö·û´®µÄת»»ÎÊÌâ (StringByte)
VB ×Ö½ÚÊý×éºÍ×Ö·û´®µÄת»»ÎÊÌâ (String<>Byte)
Posted by JiaJia 16 March,2009 (2)Comment
Ò»¡¢ Ç°ÑÔ
¡¡¡¡ Êý¾ÝÀàÐÍת»»ÔÚ±à³ÌÖо³£Óõ½£¬VB6ÌṩÁËÒ»ÕûÌ×ÀàÐÍת»»µÄº¯Êý¡£µ«ÊÇ£¬ÔÚ½øÐÐÀàÐÍת»»Ê±£¬ÓÐʱºò½ö½öÒÀ¿¿VBÌṩµÄº¯ÊýÊDz»ÄÜ´ïµ½×Ô¼ºµÄÄ¿µÄµÄ¡£Òò´Ë£¬ÐèÒª¿¼ÂÇÓÃÆäËûµÄ·½·¨À´Íê³ÉÊý¾ÝÀàÐÍת»»¡£±¾ÎĽö̸VB6ÖÐ×Ö½ÚÊý×éºÍ×Ö·û´®µÄÏ໥ת»»¹ý³ÌÖÐӦעÒâµÄÎÊÌâ¼°Æä½â¾ö°ì·¨¡£
¡¡¡¡ ÔÚVisual BasicÖÐʹÓÃByteÊý×éÖ÷ÒªÊÇΪÁË32λAPIº¯ÊýµÄ²ÎÊý´«µÝºÍº¯ÊýµÄ·µ»Ø¡£ÔÚ32λµÄVisual Basic°æ±¾ÖУ¬×Ö·û´®±»¼Ù¶¨ÎªUnicode×Ö·û£¬ÆäÖÐÿ¸ö×Ö·ûÕ¼ÓÃÁ½¸ö×Ö½Ú¡£ÏµÍ³×Ô¶¯µØ½«UnicodeµÄÁ½¸öÁ¬Ðø×Ö½Úת»»³É1¸ö×Ö½ÚµÄANSI×Ö·û¡£µ«ÊÇ£¬Èç¹û¸Ã×Ö·û´®°üº¬¶þ½øÖÆÊý¾Ý£¬ÆäÄÚÈݽ«±äµÃºÜÄÑÀí½â¡£ÀýÈ磬һ¸öºº×ÖÊÇÁ½¸ö×Ö½Ú£¬ÔÚVisual Basic 6.0Öеij¤¶È¾ÍÖ»ÊÇ1£¬Õ⽫¸øÎÒÃǼÆËãµ¥¸öºº×ֵĹú±êÂë´øÀ´Ò»Ð©Âé·³¡£ÓÐÁËByteÊý×飬ÕâЩÎÊÌâ¾Í½«ÓÈжø½â¡£
¡¡¡¡ ÁíÍ⣬Visual BasicÖеÄ×Ö·û´®ºÍCÓïÑÔÖеÄ×Ö·û´®ÓÐһЩ²»Í¬£¬±¾ÎĽ«¸ø³öÒ»¸öº¯Êý£¬°ÑC×Ö·û´®×ª»»³ÉVisual Basic×Ö·û´®¡£
¶þ¡¢ ÓÃByteÊý×é´úÌæ×Ö·û´®
¡¡¡¡ ByteÊý×é°üº¬µÄÊÇ0£255Ö®¼äµÄASCIIÂë×Ö·û£¬Ëü²»»áÏó×Ö·û´®ÄÇÑù±»ÏµÍ³×÷Ô¤´¦Àí¡£Äã¿ÉÒÔÔںܶàAPIº¯ÊýÖÐÓÃÀ´ByteÊý×é´úÌæ×Ö·û´®¡£
¡¡¡¡ ÀýÈ磬ÏÂÃæµÄ´úÂëÖÐÓÃGetSystemDirectoryÕâ¸öWindows APIº¯ÊýÀ´È¡µÃWindowsµÄϵͳ·¾¶¡£Ò»¹²ÓÐÁ½¶Î´úÂ룬һ¶Î´úÂëÊÇ´«µÝÒ»¸ö×Ö·û´®À´´æ´¢º¯Êý·µ»ØµÄϵͳ·¾¶£¬ÁíÒ»¶Î´úÂëÊÇ´«µÝÒ»¸öByteÊý×éÀ´´úÌæ×Ö·û´®¡£
¡¡¡¡ ΪÁ˸üºÃµØ±È½Ï£¬Á½¶Î´úÂëµÄ²»Í¬²¿·Ö¶¼ÓúÚÌå±ê³ö¡£¶ÁÕß¿ÉÒÔ×Ðϸ±È½ÏÕâÁ½¶Î´úÂëµÄ²îÒ죬ÕâÑùÄú»á¸üÉîÈëµØÀí½âByteÊý×éºÍ×Ö·û´®µÄ²î±ð¡£
¡¡¡¡ °ÑÕâÁ½¶Î´úÂëµÄÈκÎÒ»¶Î·ÅÈëÒ»¸ö´°ÌåÖÐÔËÐУ¬µ«»÷´°ÌåµÄ¿Õ°×ÇøÓò£¬Ä㽫»áÔÚ´°ÌåÖп´µ½WindowsµÄϵͳ·¾¶¡£
¡¡¡¡ ÏÂÃæÊÇʹÓÃ×Ö·û´®µÄ´úÂ룺
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Sub Form_Click()
¡¡ Dim n As Integer
¡¡ Dim str As String
¡¡ str = Space$(256)
¡¡ n = GetSystemDirectory(str, 256)
¡¡ str = Left$(str, n)
¡¡ Print str
End Sub
¡¡¡¡ ÔÚÉÏÃæÕâ¶Î´úÂëÖУ¬×Ö·û´®²ÎÊýlpBuffer·µ»ØWindowsµÄϵͳ·¾¶¡£ÔÚº¯Êýµ÷ÓÃ֮ǰ£¬½«±äÁ¿Ô¤¶¨Òå³É256¸ö×Ö·û£¬²¢ÔÚº¯Êý·µ»ØʱÇå³ý¶àÓàµÄ×Ö·û¡£
×¢Ò
Ïà¹ØÎĵµ£º
ÔÚVB Öе÷Óö¯Ì¬Á¬½Ó¿â
2001-11-08· · ··yesky
1 2 3 4 5 6 7 8 ÏÂÒ»Ò³
¡¡¡¡×÷ΪһÖÖ¼òµ¥Ò×ÓõÄWindows¿ª·¢»·¾³£¬Visual Basic´ÓÒ»ÍƳö¾ÍÊܵ½Á˹ã´ó±à³ÌÈËÔ±µÄ»¶Ó¡£Ëüʹ ³ÌÐòÔ±²»±ØÔÙÖ±½ÓÃæ¶Ô·×·±¸´ÔÓµÄWindowsÏûÏ¢£¬¶ø¿ÉÒÔ½«¾«Á¦Ö÷Òª¼¯ÖÐÔÚ³ÌÐò¹¦ÄܵÄʵÏÖÉÏ£¬´ó´óÌá¸ßÁ˱ ......
¾Ý˵vb6ÖÐ,×Ö ·û´®ÒÔÒÔUNICODE·½Ê½´æ´¢£¬ËùÒÔ
Private Type UDT
lngM1 As Long
lngM2 As Long
strM3 As String * 18
strM4 As String * 8
lngM5 As Long
End Type
Private Sub Command4_Click()
Dim tmp As UDT
With tmp
.lngM1 = 1
.lngM2 = 2
' .str ......
DB2ConnectionString
b2str = "Provider=MSDASQL.1;Password=a$sk6G7;Persist Security Info=True;User ID=DBA;Data Source=ConDB2SFXXK"
AccessConnectonString
accessstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DMSJK.mdb;Jet OLEDB:database password=" ......
×ÜÊö
±¾ÎÄÐðÊöÁËÈçºÎÔÚVBÖÐʵÏֿؼþµÄIobjectSafety½Ó¿Ú£¬ÒÔ±êÖ¾¸Ã¿Ø¼þÊǽű¾°²È«ºÍ³õʼ»¯°²È«µÄ¡£VB¿Ø¼þĬÈϵĴ¦Àí·½Ê½ÊÇÔÚ×¢²á±íÖÐ×¢²á×é¼þÀàÀ´±êʶÆ䰲ȫÐÔ£¬µ«ÊµÏÖIobjectSafety½Ó¿ÚÊǸüºÃµÄ·½·¨¡£±¾ÑÔÓï°üÀ¨ÁËʵÏÖ¹ý³ÌÖÐËùÐèµÄËùÓдúÂë¡£
Çë×¢Ò⣬¿Ø¼þÖ»ÓÐȷȷʵʵÊÇ°²È«µÄ£¬²ÅÄܱ»±êʶΪ“°²È«µÄ”¡£±¾ ......
'******************************************************************************************
'* ÐèҪעÒâµÄÎÊÌâ *
'******************************************************************************************
'1.INIÎļþµÄ· ......