楼主: Lisrelchen
1157 8

Visual Basic 2005 Cookbook [推广有奖]

  • 0关注
  • 62粉丝

VIP

已卖:4194份资源

院士

67%

还不是VIP/贵宾

-

TA的文库  其他...

Bayesian NewOccidental

Spatial Data Analysis

东西方数据挖掘

威望
0
论坛币
50288 个
通用积分
83.6906
学术水平
253 点
热心指数
300 点
信用等级
208 点
经验
41518 点
帖子
3256
精华
14
在线时间
766 小时
注册时间
2006-5-4
最后登录
2022-11-6

楼主
Lisrelchen 发表于 2017-1-9 05:40:27 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
  1. BOOK DETAILS:

  2. Publisher:        O'Reilly Media
  3. Categories:        OReilly , Cookbook
  4. Author:        John Clark Craig
  5. Edition:        1
  6. ISBN-10:        0596101775
  7. ISBN-13:        9780596101770
  8. Pages:        742
  9. Published:        Oct 01 2006
  10. Posted:        Jun 30 2016
  11. Language:        English
  12. Book format:        CHM
  13. Book size:        5.65 MB
复制代码

本帖隐藏的内容

Visual Basic Cookbook 2006.rar (5.62 MB, 需要: 5 个论坛币) 本附件包括:
  • Visual Basic Cookbook 2006.chm


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Cookbook Visual Basic ASIC Book

本帖被以下文库推荐

沙发
Lisrelchen(未真实交易用户) 发表于 2017-1-9 05:41:10
  1. Recipe 5.1. Using a StringBuilder
  2. Problem
  3. You need to process many pieces of string data with more efficiency than is allowed using standard .NET Framework immutable strings.

  4. Solution
  5. The StringBuilder object provides extremely fast and efficient in-place processing of string and character data. The following code demonstrates several of its powerful methods and some of the techniques you can use to speed up your string processing:

  6.         Dim workText As New System.Text.StringBuilder
  7.        
  8.         ' ----- Build a basic text block.
  9.         workText.Append("The important")
  10.         workText.Append(vbNewLine)
  11.         workText.Append("thing is not")
  12.         workText.AppendLine()
  13.         workText.AppendLine("to stop questioning.")

  14.         workText.
  15. Append("--Albert Einstein")
  16.         MsgBox(workText.ToString( ))

  17.         ' ----- Delete the trailing text.
  18.         Dim endSize As Integer = "--Albert Einstein".Length
  19.         workText.Remove(workText.Length - endSize, endSize)
  20.         MsgBox(workText.ToString( ))

  21.         ' ----- Modify text in the middle.
  22.         workText.Insert(4, "very ")
  23.         MsgBox(workText.ToString( ))

  24.         ' ----- Perform a search and replace.
  25.         workText.Replace("not", "never")
  26.         MsgBox(workText.ToString( ))

  27.         ' ----- Truncate the existing text.
  28.         workText.Length = 3
  29.         MsgBox(workText.ToString( ))
复制代码

藤椅
Lisrelchen(未真实交易用户) 发表于 2017-1-9 05:42:01
  1. Recipe 5.2. Creating a String of N Identical Characters
  2. Problem
  3. You need to create a string comprised of a single character repeated many times. These strings are sometimes useful in the formatting of ASCII text for display or printed output.

  4. Solution
  5. Create a new string of repeated characters using the String class itself. One of its overloaded constructors accepts a character to repeat and a repetition count.
复制代码

板凳
Lisrelchen(未真实交易用户) 发表于 2017-1-9 05:43:48

  1. Recipe 5.3. Creating a String by Repeating a String N Times
  2. Problem
  3. You want a string comprised of a sequence of characters repeated many times.

  4. Solution
  5. Use a StringBuilder to append as many copies of the string as desired. Then convert the result to a true string using the StringBuilder's ToString() method:

  6.         Dim fancyString As New System.Text.StringBuilder
  7.         For counter As Integer = 1 To 35
  8.            fancyString.Append("+~")
  9.         Next counter
  10.         MsgBox(fancyString.ToString())
复制代码

报纸
Lisrelchen(未真实交易用户) 发表于 2017-1-9 05:44:43
  1. Recipe 5.4. Obfuscating a String
  2. Problem
  3. You need to store a string in such a way that a user won't recognize it, but you also want to make sure that the string stays the same length and that it contains only printable ASCII characters.

  4. Solution
  5. Sample code folder: Chapter 05\ObfuscateString

  6. Process each printable character of the string by shifting its ASCII value to that of another character within the same set. The following two functions can be used to obfuscate strings in this way and then return them to their original states:

  7.         Public Function Obfuscate(ByVal origText As String) As String
  8.            ' ----- Make a string unreadable, but retrievable.
  9.            Dim textBytes As Byte( ) = _
  10.               System.Text.Encoding.UTF8.GetBytes(origText)
  11.            For counter As Integer = 0 To textBytes.Length - 1
  12.               If (textBytes(counter) > 31) And _
  13.                     (textBytes(counter) < 127) Then
  14.                  textBytes(counter) += CByte(counter Mod 31 + 1)
  15.                  If (textBytes(counter) > 126) Then _
  16.                     textBytes(counter) -= CByte(95)
  17.               End If
  18.            Next counter
  19.            Return System.Text.Encoding.UTF8.GetChars(textBytes)
  20.         End Function

  21.         Public Function DeObfuscate(ByVal origText As String) _
  22.               As String
  23.            ' ----- Restore a previously obfuscated string.
  24.            Dim textBytes As Byte( ) = _
  25.               System.Text.Encoding.UTF8.GetBytes(origText)
  26.            For counter As Integer = 0 To textBytes.Length - 1
  27.               If (textBytes(counter) > 31) And _
  28.                     (textBytes(counter) < 127) Then
  29.                  textBytes(counter) -= CByte(counter Mod 31 + 1)
  30.                  If (textBytes(counter) < 32) Then _
  31.                     textBytes(counter) += CByte(95)
  32.               End If
  33.            Next counter
  34.            Return System.Text.Encoding.UTF8.GetChars(textBytes)
  35.         End Function
复制代码

地板
Lisrelchen(未真实交易用户) 发表于 2017-1-9 05:45:13
  1. Recipe 5.5. Converting Binary Data to a Hexadecimal String
  2. Problem
  3. You need to convert a byte array to a hexadecimal string. This is handy for the display or documentation of binary data.

  4. Solution
  5. Use a bit converter to get the hexadecimal representation of each byte within a block of data. The following code generates the hexadecimal string from source data:

  6.         Dim result As String = Replace(BitConverter.ToString( _
  7.            origBytes), "-", "")
复制代码

7
Lisrelchen(未真实交易用户) 发表于 2017-1-9 05:47:52
  1. Recipe 5.6. Extracting Substrings from Larger Strings
  2. Problem
  3. You want to extract substrings located at the left end, the right end, or somewhere in the middle of a string.

  4. Solution
  5. Visual Basic 2005 strings now have a built-in method named Substring() that provides an alternative to the traditional Visual Basic functions Left(), Mid(), and Right(), although the language retains these features if you wish to use them. To emulate each of these functions, set the Substring() method's parameters appropriately. The following code shows how to do this:

  6.         Dim quote As String = "The important thing is not to " & _
  7.            "stop questioning. --Albert Einstein"
  8.        
  9.         ' ----- Left(quote, 3) … "The"
  10.            MsgBox(quote.Substring(0, 3))
  11.        
  12.         ' ----- Mid(quote, 5, 9) … "important"
  13.            MsgBox(quote.Substring(4, 9))

  14.         ' ----- Mid(quote, 58) … "Einstein"
  15.            MsgBox(quote.Substring(57))

  16.         ' ----- Right(quote, 8) … "Einstein"
  17.            MsgBox(quote.Substring(quote.Length - 8))
复制代码

8
Lisrelchen(未真实交易用户) 发表于 2017-1-9 05:48:40
  1. Recipe 5.7. Converting a String's Case
  2. Problem
  3. You want to convert a string to all uppercase, all lowercase, or mixed case (with only the first letter of each word in uppercase).

  4. Solution
  5. Sample code folder: Chapter 05\MixedCase

  6. The string methods ToUpper() and ToLower() make it easy to convert strings to upper-and lowercase, and a short special-purpose function can perform the mixed conversion. You can also use the standard Visual Basic UCase() and LCase() methods. To mix-case a string, use Visual Basic's StrConv() function.

  7. Discussion
  8. Changing strings to upper- or lowercase is standard Visual Basic fare:

  9.         ' ----- To upper case.
  10.         newString = oldString.ToUpper()
  11.         newString = UCase(oldString)
  12.        
  13.         ' ----- To lower case.
  14.         newString = oldString.ToLower()
  15.         newString = LCase(oldString)



  16. To convert the string to mixed or "proper" case, use one of the conversion methods included in the StrConv() function:

  17.         newString = StrConv(oldString, VbStrConv.ProperCase
复制代码

9
franky_sas(未真实交易用户) 发表于 2017-1-9 09:33:33

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-2-3 20:41