求助数控编程代码及解释代码

在 SegmentFault,学习技能、解决问题
每个月,我们帮助 1000 万的开发者解决各种各样的技术问题。并助力他们在技术能力、职业生涯、影响力上获得提升。
问题对人有帮助,内容完整,我也想知道答案
问题没有实际价值,缺少关键内容,没有改进余地
function uniqArray (arr) {
var resArr = []
var tempObj = {}
for (var i = 0; i & arr. i++) {
var val = arr[i]
var type = typeof (val)
if (!tempObj[val]) {
tempObj[val] = [type]
resArr.push(val)
} else if (tempObj[val].toString().indexOf(type) & 0) {
tempObj[val].push(type)
resArr.push(val)
console.log(tempObj)
return resArr
首先我不明白tempobj={}存在的意义
其次是这两个if 的作用
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
首先说一下,这个函数作用的,是去重的
uniqArray([1,2,3,4,'1',1,null,null,undefined,undefined])
[1, 2, 3, 4, "1", null, undefined]
tempObj就是一个临时对象,起到判断作用的,用来判断数组中的值,是否已经存在过了
第一个if作用:如果tempObj没有数组中对应值的类型,就代表返回的结果数组中没有出现过,就添加到返回的结果中
第二个if作用:这个作用主要是区分类似数字1和字符串"1"的区别的,
分享到微博?
关闭理由:
删除理由:
忽略理由:
推广(招聘、广告、SEO 等)方面的内容
与已有问题重复(请编辑该提问指向已有相同问题)
答非所问,不符合答题要求
宜作评论而非答案
带有人身攻击、辱骂、仇恨等违反条款的内容
无法获得确切结果的问题
非开发直接相关的问题
非技术提问的讨论型问题
其他原因(请补充说明)
我要该,理由是:
在 SegmentFault,学习技能、解决问题
每个月,我们帮助 1000 万的开发者解决各种各样的技术问题。并助力他们在技术能力、职业生涯、影响力上获得提升。本帖子已过去太久远了,不再提供回复功能。matlab一句代码,求助解释_百度知道
matlab一句代码,求助解释
:);第二句是截短成45秒.wav'cs\Desktop\dsp\myrecord,bits]=wavread('C:\x=record((fs*0+1:fs*45)[record,);Users&#92
我有更好的答案
fs*0+1 如果没猜错的话,record是一个瘦高的矩阵: fs*45就是指从第一个采样点(声音的开头)截取到45秒处对应的采样点(第fs*45个采样点)1:fs*45表达式意为(1,2,3,..,每一列是一个声道,每一行对应一个采样。fs是采样率
请问为什么有fs*0呢?
采纳率:76%
为您推荐:
其他类似问题
matlab的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。Powered by
X3.2 Designed by查看: 1529|回复: 12
求助 代码的解释 谢谢
阅读权限20
在线时间 小时
本帖最后由 tsingcea 于
22:38 编辑
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
& & Dim BRow As Long, NowRow As Long, RColumn As Integer
& & If Target.Cells.Count & 1 Then GoTo The_Exit
& & BRow = LastRow(Me)
& & RColumn = LastColumn(Me)
Private Sub Worksheet_Change(ByVal Target As Range) '复制
& & Dim secRng As Range, TheCell As Range, TheRow As Long, OldSelection As Range
& & Set OldSelection = Selection
& & With Me
& && &&&Set secRng = Application.Intersect(Columns(&B:C&), Target)
& && &&&If secRng Is Nothing Then GoTo The_Exit
尤其是红色字体的部分。非常感谢。
阅读权限30
在线时间 小时
If Target.Cells.Count & 1 Then GoTo The_Exit&&
如果当前选中单为格个数大于1 则退出程序.
Dim secRng As Range, TheCell As Range, TheRow As Long, OldSelection As Range
声明 变量SECRNG的数据类型为 单元格&&另外两个同理.
Set OldSelection = Selection
这句应该是指&&设置变量OLDSELECTION为激活单元格吧.
Set secRng = Application.Intersect(Columns(&B:C&), Target)
这句不理解,从英文意思看应该是指两个区域之间相交的区域
阅读权限50
在线时间 小时
本帖最后由 f8b1987 于
23:08 编辑
If Target.Cells.Count & 1 Then GoTo The_Exit
当选取范围的单元格超过一个的时候,就直接goto到the_exit处,不执行the_exit前的代码
阅读权限20
在线时间 小时
& & & & & & & &
多谢各位的回答。另外,UserInterfaceOnly:=True是什么意思呢?
阅读权限90
在线时间 小时
本帖最后由 yiyiyicz 于
08:01 编辑
“Set secRng = Application.Intersect(Columns(&B:C&), Target)”
设BC两列(单元格区域)与range单元格区域这两个的交叉重叠的区域为secrng
如果没有交叉重叠区域,则跳到the_exit处
“UserInterfaceOnly:=True是什么意思呢”
在worksheet.protect方法里,加入userinterfaceonly:=true即可在保护状态对工作表可编辑区域进行编辑
还可以有其他的应用,需要试一下。其语法解释如下
UserInterfaceOnly& && &Variant 类型,可选。如果为 True,则保护用户界面,但不保护宏。如果省略本参数,则保护既应用于宏也应用于用户界面。
阅读权限20
在线时间 小时
本帖最后由 tsingcea 于
02:35 编辑
yiyiyicz 发表于
“Set secRng = Application.Intersect(Columns(&B:C&), Target)”
设BC两列(单元格区域)与range单元格区 ...
非常感谢您的回答,给我提供了清晰、有力的思路。请问如果设定了UserInterFaceOnly=False,是不是就等同于不写了呢。另外,如何写一个与Set secRng = Application.Intersect(Columns(&B:C&), Target)相反的代码?我的意思就是“临时性”取消Set secRng = Application.Intersect(Columns(&B:C&), Target)和UserInterFaceOnly=True这两句代码。因为我发现这几句代码的出现可能会导致一个按钮功能的冲突,所以,我希望能够通过一个代码临时性地使这两个代码能够在这个按钮的操作中失去作用。谢谢!!!!!这个“反”代码,如何写呢?
阅读权限90
在线时间 小时
本帖最后由 yiyiyicz 于
05:59 编辑
“设定了UserInterFaceOnly=False,是不是就等同于不写了呢”
这样理解,偏差太大了。肯定不是
在“是”与“非”的世界里,不是“是”,就是“非”,两者必须选一个。比如,刷屏=T,是sheet默认的。那么当你希望取消刷屏,就需要让刷屏=F
后面的不太明白
交叉重叠区域和人机交互之间,好像没有关系啊,怎么会发生冲突呢
或者写一段VBA,可能好理解
阅读权限20
在线时间 小时
& & & & & & & &
本帖最后由 tsingcea 于
11:31 编辑
yiyiyicz 发表于
“设定了UserInterFaceOnly=False,是不是就等同于不写了呢”
这样理解,偏差太大了。肯定不是
在“是”与 ...
您的回答让我受益匪浅。为了更加详细地说明我的情况,我觉得有必要上传一个附件,请您给帮忙修改修改。因为,鄙人能力有限,实在是想不出什么解决之道了。
脑袋都想破了,就是无法解决这一难题。
就是“在锁定的单元格中禁止粘贴”这一难题。还望大师费心,帮助解决这一难题啊。具体情况请看附件。
密码:123456
阅读权限90
在线时间 小时
& & & & & & & &
tsingcea 发表于
您的回答让我受益匪浅。为了更加详细地说明我的情况,我觉得有必要上传一个附件,请您给帮忙修改修改。 ...
代码是复制来的?
这么长的代码,还得看一阵子。
另外,还是请简单明了的讲清楚,你希望达到什么效果?
6楼中,要临时性地取消什么限制或者功能》动态设定某个单元区域,正常情况不允许操作;当在特定情况下,这个区域可以复制。
还是别的什么意思?
阅读权限90
在线时间 小时
这是你附件中的代码Private Sub CommandButton4_Click() '按钮粘贴
On Error GoTo Err
& && &&&Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
& && &&&xlNone, SkipBlanks:=False, Transpose:=False
& && &&&Exit Sub
Err:
If Application.CutCopyMode = False Then
& & MsgBox &您还没复制,或请重新复制。&
Else
& & MsgBox &如果粘贴整行或整列,请注意粘贴位置;& & Chr(10) & &另外,本命令在剪切模式下不可使用。&
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
& & Dim BRow As Long, NowRow As Long, RColumn As Integer
& & If Target.Cells.Count & 1 Then GoTo The_Exit
& & BRow = LastRow(Me)
& & RColumn = LastColumn(Me)
& & With Me
& && &&&On Error Resume Next
& && &&&.Protect Password:=&123456&, UserInterfaceOnly:=True
& && &&&If Err.Number && 0 Then
& && && && &On Error GoTo 0
& && && && &MsgBox prompt:=&工作表有密码保护,本代码无法正常运行!&, Buttons:=vbOKOnly + vbCritical
& && && && &GoTo The_Exit
& && &&&End If
& && &&&On Error GoTo 0
& && &&&If BRow & 4 Then '若不存在记录,则解除第4行所有限制,此时可在第4行设置或修改公式
& && && && &.Range(.Cells(4, 1), .Cells(4, RColumn)).Borders.LineStyle = xlContinuous '添加框线
& && && && &.Range(.Cells(4, 1), .Cells(4, RColumn)).Locked = False '解除锁定
& && &&&Else '否则总是锁定第4行公式所在单元格,不可编辑
& && && && &.Range(.Cells(4, 7), .Cells(4, 8)).Locked = True '锁定
& && && && &.Range(.Cells(4, 10), .Cells(4, 12)).Locked = True
& && && && &.Range(.Cells(4, 14), .Cells(4, 16)).Locked = True
& && && && &.Range(.Cells(4, 18), .Cells(4, 20)).Locked = True
& && &&&End If
& & End With
& & NowRow = Target.Row
& & If NowRow & 4 Then '至少大于第4行才执行复制公式等操作,本例第4行为第一条记录所在行
& && &&&With Me
& && && && &If NowRow = BRow + 1 Then '若当前行正好位于最底部记录的下一行,则
& && && && && & .Range(.Cells(NowRow, 1), .Cells(NowRow, RColumn)).Borders.LineStyle = xlContinuous '添加框线
& && && && && & .Range(.Cells(NowRow, 1), .Cells(NowRow, 6)).Locked = False '解除锁定
& && && && && & .Cells(NowRow, 9).Locked = False
& && && && && & .Cells(NowRow, 13).Locked = False
& && && && && & .Cells(NowRow, 17).Locked = False
& && && && && & .Cells(NowRow, 21).Locked = False
& && && && &Else
& && && && && & If NowRow &= BRow Then '若当前行位于已有记录区,则清除底部追加的空记录(若存在的话)相关设置
& && && && && && &&&NowRow = BRow + 1 '借用NowRow变量,让NowRow指向最底部记录的下一行
& && && && && && &&&.Range(.Cells(NowRow, 1), .Cells(NowRow, RColumn)).Borders.LineStyle = xlNone '去除框线
& && && && && && &&&.Range(.Cells(NowRow, 1), .Cells(NowRow, 6)).Locked = True '重新锁定
& && && && && && &&&.Cells(NowRow, 9).Locked = True
& && && && && && &&&.Cells(NowRow, 13).Locked = True
& && && && && && &&&.Cells(NowRow, 17).Locked = True
& && && && && && &&&.Cells(NowRow, 21).Locked = True
& && && && && & End If
& && && && &End If
& && &&&End With
& & End If
The_Exit:
End Sub
Private Sub Worksheet_Change(ByVal Target As Range) '复制
& & Dim secRng As Range, TheCell As Range, TheRow As Long, OldSelection As Range
& & Set OldSelection = Selection
& & With Me
& && &&&Set secRng = Application.Intersect(Columns(&B:C&), Target)
& && &&&If secRng Is Nothing Then GoTo The_Exit
& && &&&On Error Resume Next
& && &&&.Protect Password:=&123456&, UserInterfaceOnly:=True
& && &&&If Err.Number && 0 Then
& && && && &On Error GoTo 0
& && && && &MsgBox prompt:=&工作表有密码保护,本代码无法正常运行!&, Buttons:=vbOKOnly + vbCritical
& && && && &GoTo The_Exit
& && &&&End If
& && &&&On Error GoTo Error_Handler
& && &&&With Application
& && && && &.EnableCancelKey = xlDisabled
& && && && &.ScreenUpdating = False
& && && && &.EnableEvents = False
& && &&&End With
& && &&&For Each TheCell In secRng.Cells
& && && && &If Len(TheCell) & 0 Then
& && && && && & TheRow = TheCell.Row
& && && && && & .Cells(4, 7).Copy '以第1条记录的公式为参考进行复制(下同),本例,记录从第3行起始
& && && && && & .Cells(TheRow, 7).PasteSpecial Paste:=xlPasteFormulas
& && && && && & Application.CutCopyMode = False
& && && && && & .Cells(4, 8).Copy
& && && && && & .Cells(TheRow, 8).PasteSpecial Paste:=xlPasteFormulas
& && && && && & Application.CutCopyMode = False
& && && && && & .Range(.Cells(4, 10), .Cells(4, 12)).Copy
& && && && && & .Range(.Cells(TheRow, 10), .Cells(TheRow, 12)).PasteSpecial Paste:=xlPasteFormulas
& && && && && & Application.CutCopyMode = False
& && && && && & .Range(.Cells(4, 14), .Cells(4, 16)).Copy
& && && && && & .Range(.Cells(TheRow, 14), .Cells(TheRow, 16)).PasteSpecial Paste:=xlPasteFormulas
& && && && && & Application.CutCopyMode = False
& && && && && & .Range(.Cells(4, 18), .Cells(4, 20)).Copy
& && && && && & .Range(.Cells(TheRow, 18), .Cells(TheRow, 20)).PasteSpecial Paste:=xlPasteFormulas
& && && && && & Application.CutCopyMode = False
& && && && &End If
& && &&&Next TheCell
& && &&&On Error Resume Next '忽略不存在公式时的错误
& && &&&.Cells.SpecialCells(xlCellTypeFormulas).FormulaHidden = True
& && &&&Application.EnableEvents = True
& && &&&GoTo The_Exit
& & End With
Error_Handler:
& & With Application
& && &&&.EnableEvents = True
& && &&&.ScreenUpdating = True
& & End With
& & MsgBox &出现异常!代码中止。&
The_Exit:
& & With OldSelection
& && &&&.Parent.Select
& && &&&.Select
& & End With
& & Application.ScreenUpdating = True
& & Set OldSelection = Nothing
& & Set secRng = Nothing
& & Set TheCell = Nothing
End Sub
Private Function LastRow(Sht As Worksheet) As Long
& & '本函数返回指定工作表有内容的最后一行的行号
& & '参数Sht代表指定的工作表
& & Dim TheCell As Range, EndRow1 As Long, EndRow2 As Long
& & LastRow = 1 '确保一次赋值
& & With Sht
& && &&&Set TheCell = .Cells.Find(What:=&*&, After:=.Cells(1, 1), LookIn:=xlFormulas, LookAt:=xlPart, _
& && &&&SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False, MatchByte:=False, searchformat:=False)
& && &&&If Not TheCell Is Nothing Then EndRow1 = TheCell.Row '按“公式”查找得到的行号
& && &&&Set TheCell = .Cells.Find(What:=&*&, After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, _
& && &&&SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False, MatchByte:=False, searchformat:=False)
& && &&&If Not TheCell Is Nothing Then EndCol2 = TheCell.Row '按“值”查找得到的行号
& && &&&If EndRow1 && EndRow2 Then
& && && && &If EndRow1 & EndRow2 Then
& && && && && & LastRow = EndRow1
& && && && &Else
& && && && && & LastRow = EndRow2
& && && && &End If
& && &&&Else
& && && && &If EndRow1 & 0 Then
& && && && && & LastRow = EndRow1
& && && && &End If
& && &&&End If
& & End With
End Function
Private Function LastColumn(Sht As Worksheet) As Integer
& & '本函数返回指定工作表有内容的最后一列的列号
& & '参数Sht代表指定的工作表
& & Dim TheCell As Range, EndCol1 As Integer, EndCol2 As Integer
& & LastColumn = 1 '确保一次赋值
& & With Sht
& && &&&Set TheCell = .Cells.Find(What:=&*&, After:=.Cells(1, 1), LookIn:=xlFormulas, LookAt:=xlPart, _
& && &&&SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False, MatchByte:=False, searchformat:=False)
& && &&&If Not TheCell Is Nothing Then EndCol1 = TheCell.Column '按“公式”查找得到的列号
& && &&&Set TheCell = .Cells.Find(What:=&*&, After:=.Cells(1, 1), LookIn:=xlValues, LookAt:=xlPart, _
& && &&&SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False, MatchByte:=False, searchformat:=False)
& && &&&If Not TheCell Is Nothing Then EndRow2 = TheCell.Column '按“值”查找得到的列号
& && &&&If EndCol1 && EndCol2 Then
& && && && &If EndCol1 & EndCol2 Then
& && && && && & LastColumn = EndCol1
& && && && &Else
& && && && && & LastColumn = EndCol2
& && && && &End If
& && &&&Else
& && && && &If EndCol1 & 0 Then
& && && && && & LastColumn = EndCol1
& && && && &End If
& && &&&End If
& & End With
End Function
复制代码
最新热点 /1
ExcelHome每周都有线上直播公开课,
国内一流讲师真身分享,高手贴身答疑,
赶不上直播还能看录像,
关键居然是免费的!
厚木哥们都已经这么努力了,
你还好意思说学不好Office。
玩命加载中,请稍候
玩命加载中,请稍候
Powered by
本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任! & & 本站特聘法律顾问:徐怀玉律师 李志群律师

我要回帖

更多关于 1225违章代码 解释 的文章

 

随机推荐