帮朋友改的一小段关键词分析代码; 含两个单词复合计数
Private Function CollectWords() As Dictionary(Of String, Integer)
'Create a new dictionary
Dim table As New Dictionary(Of String, Integer)
'Prompt for the user
Console.WriteLine(
"Enter a line : ")
'Get the user's input
Dim input As String = Console.ReadLine()
'Split the line and make an array of words
Dim words As String() = input.Split()
Dim wordPrev As String = ""
'Search the array
For Each word In words
'We can get the lowercase, not necessary here
Dim wordKey As String = word.ToLower()
'If the dictionay contains the words
If table.ContainsKey(wordKey) Then
'increment
table(wordKey) = table(wordKey) + 1
Else
'add a new word with a count of 1 in the dictionary
table.Add(wordKey, 1)
End If
Dim wordKey2 As String = (wordPrev + " " + word).ToLower()
If wordPrev <> "" Then
If table.ContainsKey(wordKey2) Then
'increment
table(wordKey2) = table(wordKey2) + 1
Else
'add a new word with a count of 1 ......
Option Explicit
Private Type UNICODE_STRING
Length As Integer
MaximumLength As Integer
Buffer As Long
End Type
Private Type OBJECT_ATTRIBUTES
Length As Long
RootDirectory As Long
ObjectName As Long
Attributes As Long
SecurityDescriptor As Long
SecurityQualityOfService As Long
End Type
Private Type KEY_VALUE_FULL_INFORMATION
TitleIndex As Long
Type As Long
DataOffset As Long
DataLength As Long
NameLength As Long
Name As Long
End Type
Private Type LARGE_INTEGER
Lowpart As Long
Highpart As Long
End Type
Private Type KEY_BASIC_INFORMATION
LastWriteTim As LARGE_INTEGER
TitleIndex As Long
&n ......
VERSION 5.00
Begin VB.Form frmMain
BorderStyle = 1 'Fixed Single
Caption = "Reg Demo"
ClientHeight = 6570
ClientLeft = 45
ClientTop = 435
ClientWidth = 7695
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 6570
ScaleWidth = 7695
StartUpPosition = 2 'CenterScreen
Begin VB.TextBox txtData
Height = 270
Left = 1200
TabIndex = 6
Text = "ExCFormParser"
Top = 5400
Width = 6375
End
Begin VB.TextBox txtRegKey
Height = 270
Left = 1200
TabIndex = 4
Text = "\Registry\Machine"
Top = 5040
Width = 6375
End
Begin VB.CommandButton cmdEnd
Caption = "End"
Enabled = ......
给出代码如下:
Type WAPPushPDUStruct
SMSCLen As String
SMSCType As String
SMSC As String
PROTOCOL As String
TPMRBase As String
RePhoneNumLen As String
RePhoneNumType As String
RePhoneNum As String
TPPID As String
TPDSC As String
TPVP As String
MSGLen As String
WAPPUSHHeadLen As String
WAPPUSHFlag As String
DATALen As String
WAPPUSHCOMBFlag As String
Total As String
MSGID As String
WapPushUDH As String
WapPushPUD As String
' WAPPUSHBegin As String
' WSP As String
' Flag ......
如今OCX控件在编程中已占领了很重要的地位,我们可以利用OCX控件完成一些相当复杂的编程操作。同时OCX控件还有利于主程序的简单化、功能的重用、隐藏程序实现细节、便于升级、传播方便等优点。现在我们可以利用VB 5.0方便地制作出自己的OCX控件供我们在编程中使用,同时还可以把它送给你周围喜欢编程的朋友!下面列出制作OCX控件的步骤:
一:新建OCX
打开VB 5.0选择新建工程在对话框中选择ActiveX控件,打开后会见一空的文档,这就是OCX控件的初始界面。想看一看空OCX控件的效果吗?选择“添加工程”选中标准EXE,这时你就可以像调用其它控件一样在左边的工具栏里选择刚才新建的OCX控件图标,放在标准的EXE文档中看一看有什么效果!(什么也没有!)自然因为刚才的OCX文档是空的嘛。
二:创建界面
一般我们用VB创建OCX控件都是在我们的控件里添加其它的控件来组合成一个完整的控件(也可以让它只完成某种算法),比如:你可以在上面添加一按钮、编辑框,这时你再用第一部的方法看一看效果,是不是控件上多了一个按钮和一个编辑框。
三:OCX属性
一个OCX控件有许多的属性,比如控件背景是否透明(BackStyle) ......
教你如何用VB做控件*.ocx
一个控件有很多事件如:Click、MouseDown、MouseUp、MouseMove等。要触发这些事件都需要你加入代码。在控件的声明处加入Public Event Click()就表明该控件有一“Click”事件。自己编写的控件有什么事件就在声明处加几条事件
如今OCX控件在编程中已占领了很重要的地位,我们可以利用OCX控件完成一些相当复杂的编程操作.同时OCX 控件还有利于主程序的简单化、功能的重用、隐常程序实现细节、便于升级、传播方便等优点。现在我们可以利用VB 5.0方便的制作出自己的OCX控件供我们在编程中使用同时还可以把它送给你周围喜欢编程的朋友!
下面列出制作OCX控件的步骤:
一:新建OCX 打开VB 5.0选择新建工程在对话框中选择ActiveX 控件(如图一(map1.gif))打开后会见一空的文档这就是 OCX控件的初始界面。想看一看空OCX控件的效果吗?选择“添加工程”选中标准EXE,这时你就可以像调用其它控件一样在左边的工具栏里选择刚才新建的OCX控件图标放在标准的EXE文档中看一看有什么效果!(什么也没有!) 自然因为刚才的OCX文档是空的嘛(废话太多,数个痰盂向我飞来)!
二:创建界面
一般我们用VB创建OCX控件都是在我们的控件里添加 ......