评论源代码是为了业余爱好者 [英] Commenting source code is for amateurs

查看:47
本文介绍了评论源代码是为了业余爱好者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

12岁的天才功能用于计算句子中的英语单词:


''这是我计算字符串中英语单词的函数

's是用你的话来计算的字符串

''返回一个整数作为找到的单词数

公共函数iCW(ByVal s As String)As Integer

''我们开始声明变量来计算单词

Dim c As Integer

''这是用于下一循环的变量

''检查字符串中的每个字符s

Dim i As Integer

''现在检查字符串中的所有字符s

''从第一个字母开始,i = 1

''到最后一个字符,s.Length

对于i = 1到s。长度

''检查是char是空格

如果Mid(s,i,1)=" "然后

''如果它是一个空格,增加字数WordCount

c + = 1

''如果不是,那么做没有

结束如果

''继续检查单词,直到不再有

下一页

''返回单词计数,c

''加1后补偿第一个空格前的字

返回c + 1

结束函数

用于计算句子中英语单词的半专业解决方案:


公共函数WordCount(ByVal Text As String)As Long

While InStr(文字,")'删除双倍空格

替换(文字,",")

结束时

如果替换(文字,",,)=""然后返回0''只有空格

Dim WordCount As Long

For i = 1 to Len(Text)

If Mid(s,i ,1)=" "然后WordCount + = 1

下一页

返回WordCount + 1

结束功能


专业版解决方案与半专业版相同,但没有评论


MF

The 12 years old genius function to count english words in a sentence:

'' This is my function to count english words in your string
'' s is the string with your words to be counted
'' Returns an integer as the number of words found
Public Function iCW(ByVal s As String) As Integer
'' We start declaring the variable to count words
Dim c As Integer
'' This is the variable used in the for next loop
'' to check every char in your string s
Dim i As Integer
'' Now check all chars in your string s
'' Starts with the 1st char, i = 1
'' up to last char, s.Length
For i = 1 To s.Length
'' check is the char is a space
If Mid(s, i, 1) = " " Then
'' if it is a space, increment the word count WordCount
c += 1
'' if it is not, then do nothing
End If
'' continue to check words until no more
Next
'' return the word count, c
'' after adding 1 to compensate for the word before the first space
Return c + 1
End Function
The semi-pro solution to count english words in a sentence:

Public Function WordCount(ByVal Text As String) As Long
While InStr(Text, " ") '' remove double spaces
Replace(Text, " ", " ")
End While
If Replace(Text, " ", "") = "" Then Return 0 '' only spaces
Dim WordCount As Long
For i = 1 To Len(Text)
If Mid(s, i, 1) = " " Then WordCount += 1
Next
Return WordCount + 1
End Function

The pro solution is the same as the semi-pro but without comments

MF

推荐答案

你有问题吗?

" Marian F." <否**** @ NoSpam.Net>在留言中写道

news:uf ************** @ tk2msftngp13.phx.gbl ...
Do you have a question?
"Marian F." <No****@NoSpam.Net> wrote in message
news:uf**************@tk2msftngp13.phx.gbl...
这位12岁的天才在一个句子中计算英语单词的功能:

''这是我在你的字符串中计算英语单词的功能
's是用你的单词计算的字符串
''返回一个整数作为找到的单词数
公共函数iCW(ByVal s As String)作为整数
''我们开始声明变量来计算单词
Dim c As Integer
''这是用于下一个循环的变量
''检查字符串中的每个字符串
Dim i As Integer
''现在检查字符串中的所有字符s
''从第一个字母开始,我= 1
''到最后一个字符,s.Length
对于i = 1到s.Length
''检查是char是一个空间
如果Mid(s,i,1)=" "然后
''如果它是一个空格,增加字数WordCount
c + = 1
''如果不是,那么什么都不做
结束如果
''继续检查单词,直到没有更多
''返回单词计数,c'/'''在添加1之后补偿第一个空格前的单词
返回c + 1
结束功能

用于计算句子中英语单词的半专业解决方案:

公共功能WordCount(ByVal Text As String)As long
InStr(文字,")删除双重空格
替换(文字,",")
结束时
如果替换(文字, "","")=""然后返回0''只有空格
Dim WordCount为长
对于i = 1到Len(文本)
如果Mid(s,i,1)=" "然后WordCount + = 1
下一页
返回WordCount + 1
结束功能

专业解决方案与半专业版相同但没有评论

MF
The 12 years old genius function to count english words in a sentence:

'' This is my function to count english words in your string
'' s is the string with your words to be counted
'' Returns an integer as the number of words found
Public Function iCW(ByVal s As String) As Integer
'' We start declaring the variable to count words
Dim c As Integer
'' This is the variable used in the for next loop
'' to check every char in your string s
Dim i As Integer
'' Now check all chars in your string s
'' Starts with the 1st char, i = 1
'' up to last char, s.Length
For i = 1 To s.Length
'' check is the char is a space
If Mid(s, i, 1) = " " Then
'' if it is a space, increment the word count WordCount
c += 1
'' if it is not, then do nothing
End If
'' continue to check words until no more
Next
'' return the word count, c
'' after adding 1 to compensate for the word before the first space
Return c + 1
End Function
The semi-pro solution to count english words in a sentence:

Public Function WordCount(ByVal Text As String) As Long
While InStr(Text, " ") '' remove double spaces
Replace(Text, " ", " ")
End While
If Replace(Text, " ", "") = "" Then Return 0 '' only spaces
Dim WordCount As Long
For i = 1 To Len(Text)
If Mid(s, i, 1) = " " Then WordCount += 1
Next
Return WordCount + 1
End Function

The pro solution is the same as the semi-pro but without comments

MF



我感谢锅把水壶称为黑色,因为这样做了

它非常清楚只有''专业''sissies使用Visual Basic。


-

<%= Clinton Gallagher,结果两倍 - 成本的一半

建筑与建筑电子商务咨询 - 软件开发

NET cs ********* @ REMOVETHISTEXTmetromilwaukee.com

URL http:// www.metromilwaukee.com/clintongallagher/


" Marian F." <否**** @ NoSpam.Net>在留言中写道

news:uf ************** @ tk2msftngp13.phx.gbl ...
I thank the pot for calling the kettle black as doing so makes
it perfectly clear that only ''professional'' sissies use Visual Basic.

--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET cs*********@REMOVETHISTEXTmetromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/

"Marian F." <No****@NoSpam.Net> wrote in message
news:uf**************@tk2msftngp13.phx.gbl...
这位12岁的天才在一个句子中计算英语单词的功能:

''这是我在你的字符串中计算英语单词的功能
's是用你的单词计算的字符串
''返回一个整数作为找到的单词数
公共函数iCW(ByVal s As String)作为整数
''我们开始声明变量来计算单词
Dim c As Integer
''这是用于下一个循环的变量
''检查字符串中的每个字符串
Dim i As Integer
''现在检查字符串中的所有字符s
''从第一个字母开始,我= 1
''到最后一个字符,s.Length
对于i = 1到s.Length
''检查是char是一个空间
如果Mid(s,i,1)=" "然后
''如果它是一个空格,增加字数WordCount
c + = 1
''如果不是,那么什么都不做
结束如果
''继续检查单词,直到没有更多
''返回单词计数,c'/'''在添加1之后补偿第一个空格前的单词
返回c + 1
结束功能

用于计算句子中英语单词的半专业解决方案:

公共功能WordCount(ByVal Text As String)As long
InStr(文字,")删除双重空格
替换(文字,",")
结束时
如果替换(文字, "","")=""然后返回0''只有空格
Dim WordCount为长
对于i = 1到Len(文本)
如果Mid(s,i,1)=" "然后WordCount + = 1
下一页
返回WordCount + 1
结束功能

专业解决方案与半专业版相同但没有评论

MF
The 12 years old genius function to count english words in a sentence:

'' This is my function to count english words in your string
'' s is the string with your words to be counted
'' Returns an integer as the number of words found
Public Function iCW(ByVal s As String) As Integer
'' We start declaring the variable to count words
Dim c As Integer
'' This is the variable used in the for next loop
'' to check every char in your string s
Dim i As Integer
'' Now check all chars in your string s
'' Starts with the 1st char, i = 1
'' up to last char, s.Length
For i = 1 To s.Length
'' check is the char is a space
If Mid(s, i, 1) = " " Then
'' if it is a space, increment the word count WordCount
c += 1
'' if it is not, then do nothing
End If
'' continue to check words until no more
Next
'' return the word count, c
'' after adding 1 to compensate for the word before the first space
Return c + 1
End Function
The semi-pro solution to count english words in a sentence:

Public Function WordCount(ByVal Text As String) As Long
While InStr(Text, " ") '' remove double spaces
Replace(Text, " ", " ")
End While
If Replace(Text, " ", "") = "" Then Return 0 '' only spaces
Dim WordCount As Long
For i = 1 To Len(Text)
If Mid(s, i, 1) = " " Then WordCount += 1
Next
Return WordCount + 1
End Function

The pro solution is the same as the semi-pro but without comments

MF






坏消息Marian - 专家评论他们的代码。


也许你应该评论哪个版本是哪个,然后你不会在你的最后声明中混淆半专业版和专业版。


" ; Marian F." <否**** @ NoSpam.Net>在留言中写道

news:uf ************** @ tk2msftngp13.phx.gbl ...
Bad news Marian - Pros comment their code.

Maybe you should have commented which version was which, then you wouldn''t
have mixed up semi-pro and pro versions in your final statement.

"Marian F." <No****@NoSpam.Net> wrote in message
news:uf**************@tk2msftngp13.phx.gbl...
这位12岁的天才在一个句子中计算英语单词的功能:

''这是我在你的字符串中计算英语单词的功能
's是用你的单词计算的字符串
''返回一个整数作为找到的单词数
公共函数iCW(ByVal s As String)作为整数
''我们开始声明变量来计算单词
Dim c As Integer
''这是用于下一个循环的变量
''检查字符串中的每个字符串
Dim i As Integer
''现在检查字符串中的所有字符s
''从第一个字母开始,我= 1
''到最后一个字符,s.Length
对于i = 1到s.Length
''检查是char是一个空间
如果Mid(s,i,1)=" "然后
''如果它是一个空格,增加字数WordCount
c + = 1
''如果不是,那么什么都不做
结束如果
''继续检查单词,直到没有更多
''返回单词计数,c'/'''在添加1之后补偿第一个空格前的单词
返回c + 1
结束功能

用于计算句子中英语单词的半专业解决方案:

公共功能WordCount(ByVal Text As String)As long
InStr(文字,")删除双重空格
替换(文字,",")
结束时
如果替换(文字, "","")=""然后返回0''只有空格
Dim WordCount为长
对于i = 1到Len(文本)
如果Mid(s,i,1)=" "然后WordCount + = 1
下一页
返回WordCount + 1
结束功能

专业解决方案与半专业版相同但没有评论

MF
The 12 years old genius function to count english words in a sentence:

'' This is my function to count english words in your string
'' s is the string with your words to be counted
'' Returns an integer as the number of words found
Public Function iCW(ByVal s As String) As Integer
'' We start declaring the variable to count words
Dim c As Integer
'' This is the variable used in the for next loop
'' to check every char in your string s
Dim i As Integer
'' Now check all chars in your string s
'' Starts with the 1st char, i = 1
'' up to last char, s.Length
For i = 1 To s.Length
'' check is the char is a space
If Mid(s, i, 1) = " " Then
'' if it is a space, increment the word count WordCount
c += 1
'' if it is not, then do nothing
End If
'' continue to check words until no more
Next
'' return the word count, c
'' after adding 1 to compensate for the word before the first space
Return c + 1
End Function
The semi-pro solution to count english words in a sentence:

Public Function WordCount(ByVal Text As String) As Long
While InStr(Text, " ") '' remove double spaces
Replace(Text, " ", " ")
End While
If Replace(Text, " ", "") = "" Then Return 0 '' only spaces
Dim WordCount As Long
For i = 1 To Len(Text)
If Mid(s, i, 1) = " " Then WordCount += 1
Next
Return WordCount + 1
End Function

The pro solution is the same as the semi-pro but without comments

MF



这篇关于评论源代码是为了业余爱好者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆