在开始之前,我想指出我将这个问题标记为 VBA,因为我实际上无法为 Winwrap 创建新标签,而且有人告诉我 Winwrap 与 VBA 几乎相同。
我正在研究 SPSS V19.0,我正在尝试编写一个代码来帮助我识别和分配值标签给在指定变量(或所有变量)中没有标签的所有值。
下面的伪代码适用于它是单个变量的版本(可能由文本框输入,或者可能通过 SPSS Stats 程序中的自定义对话框发送(从给定变量名称的语法中调用 .sbs 文件)。
这是伪代码:
Sub Main(variable As String)
On Error GoTo bye
'Variable Declaration:
Dim i As Integer, intCount As Integer
Dim strValName As String, strVar As String, strCom As String
Dim varLabels As Variant 'This should be an array of all the value labels in the selected record
Dim objSpssApp As 'No idea what to put here, but I want to select the spss main window.
'Original Idea was to use two loops
'The first loop would fill an array with the value lables and use the index as the value and
'The second loop would check to see which values already had labels and then
'Would ask the user for a value label to apply to each value that didn't.
'loop 1
'For i = 0 To -1
'current = GetObject(variable.valuelist(i)) 'would use this to get the value
'Set varLabels(i) = current
'Next
'Loop for each number in the Value list.
strValName = InputBox("Please specify the variable.")
'Loop for each number in the Value list.
For i = 0 To varLabels-1
If IsEmpty (varLabels(i)) Then
'Find value and ask for the current value label
strVar = InputBox("Please insert Label for value "; varLabels(i);" :","Insert Value Label")
'Apply the response to the required number
strCom = "ADD VALUE LABELS " & strVar & Chr$(39) & intCount & Chr$(39) & Chr$(39) & strValName & Chr$(39) &" ."
'Then the piece of code to execute the Syntax
objSpssApp.ExecuteCommands(strCom, False)
End If
'intCount = intCount + 1 'increase the count so that it shows the correct number
'it's out of the loop so that even filled value labels are counted
'Perhaps this method would be better?
Next
Bye:
End Sub
这绝不是功能代码,它基本上只是我想要实现的过程的伪代码我只是在寻找一些帮助,如果你可以的话,那将是神奇的。
非常感谢提前
马夫