Exception while adding TimeScaleValue MS Project - visual-studio-2010

I'm getting this exception in this code:
Dim TSV As TimeScaleValues
TSV = ActiveProject.Task(ntask).Resources(nresource).TimeScaleData(nStartDate , nEndDate, PjResourceTimescaledData.pjResourceTimescaledActualWork, PjTimescaleUnit.pjTimescaleDays, 1)
TSV.item(1).Add( nMinutes , 1 ) ' nMinutes is the value of time in minutes. The error occours in this line !!!!
When I execute the last line I get this exception
Invalid value for argument.
Error code -2146827187
{Microsoft.Office.Interop.MSProject.TimeScaleValue Add(System.Object, System.Object)}
The estrange thing is that I got this example right from this microsoft reference page.
What I'm trying to do is add a time to time scale on project.

I solved the problem.
I was setting the value in the wrong place.
Seems confuse, but I was trying to get the time scale value from resource, but the right place to set the values is on assignments.
I was doing this..
TSV = ActiveProject.Task(ntask).Resources(nresource).TimeScaleData...
The right code is like:
TSV = ActiveProject.Assignments.TimeScaleData..
For each resource in the task is created one assingment, so teh final code is like:
For Each assignment As Assignment In Task.Assigments
if assignment.Resource.WindowsUserAccount = <desiredAccount> then
tsv = assingment.TimeScaleData..
end if
Next

Related

Why am I getting this error, when character is fully loaded?

I am trying to insert an animation into my code for the first time. Here is my code:
1 local player = game.Players.LocalPlayer
2 local char = player.Character or player.CharacterAdded:Wait()
3 local hum = char:WaitForChild("Humanoid")
4
5 local animaInstance = Instance.new("Animation")
6 animaInstance.AnimationId = "rbxassetid://4641537766"
7
8 local fireBallAnim = hum.LoadAnimation(animaInstance)
9 fireBallAnim:Play()
I am getting the error
The function LoadAnimation is not a member of Animation
I know the character has fully loaded, so I don't understand. Could I be getting this error if there is something wrong with the animation itself? What else am I missing out?
Thanks
local fireBallAnim = hum:LoadAnimation(animaInstance)
This is a very confusing message for the error. The only problem is that you've called a member function with a . as opposed to a :. Switching it to a colon will fix your error.
When you call a function on an object with a colon, it is automatically inserting the object as the first argument. A fun example of this can be seen with tables :
-- insert an object into the table 't'
local t = {}
table.insert(t, 1)
-- can also be written as...
t.insert(t, 1)
-- which is the same as...
t:insert(1)
All of these calls do the same thing. Calling the function with : is syntactic sugar for putting the t object as the first argument. So in your code, what's happening is you are calling LoadAnimation like this :
local fireBallAnim = hum.LoadAnimation(<a humanoid object needs to go here>, <animation>)
But since you are passing in the animation where the Humanoid is supposed to go, it is trying to find the LoadAnimation function on the animation object and failing.

metafor package, rma.uni, mods, Model matrix contains character variables

I'm trying to run a meta-regression with MD's as dependent variable. I want to add a numeric moderator (year published) to the rma.uni function.
Formula so far:
metafor::rma.uni(yi=MCID12, sei=SE12, method="FE", data=Pain, slab=paste(Pain$Author, Pain$Year), weighted=TRUE, subset=(Pain$outcomegruppe=="9"), mods =("Pain$Year") )
I always get the error message:
Error in metafor::rma.uni(yi = MCID12, sei = SE12, method = "FE", data = Pain, :
Model matrix contains character variables.
My "Year" veriable is definetly numeric. As soon as I don't use the "mods" argument, everything works normal.
Could anyone help me with this problem?
Thanks in advance!
Don't put Year in quotes. Also, you don't need the Pain$ parts and weighted=TRUE is the default. This should do it:
metafor::rma.uni(yi=MCID12, sei=SE12, method="FE", data=Pain, slab=paste(Author, Year),
subset=(outcomegruppe=="9"), mods=~Year)

Add one spot to a value

Its possible to book appointments in my app and I get the queue line value from this code to display for the users in the app:
Text = $"Spot {_Class.Slots.WaitList}";
What im trying to get here is to show the queue that person has. The issue is that the value im getting from that line is the value that says how many people there are in the line. So if a person books an appointment the value has to increase from e.g 2 to 3.
EDIT:
The value im getting from this code I get from the database:
Text = $"Spot {_Class.Slots.WaitList}";
The value is 1 (just an example) but i need the value to be +1 every time.
I tried to do this:
Text = $"Spot {_Class.Slots.WaitList + "1"}";
But it added 10 instead of 1.
What's the type of WaitList field/property?
I don't see a reason why this wouldn't work:
Text = $"Spot {_Class.Slots.WaitList + 1}";

Getting error Object Required: when indexing an array

Here's the code:
Set page = Sys.Browser("iexplore").Page...
Set files_table = page.FindChildByXPath("//div[#class='dojoxGridContent']//div[#role='presentation']", True)
Set files_table_rows = files_table.children
row_index = 0
While Not file_found
lnk_Refresh.Click
aqUtils.Delay(6000)
Set cell = files_table_rows(row_index) //error thrown on this line
During debugging I can see both objects files_table and files_table_rows and they're both correct and have the correct data. When we try to get the first element in files_table_rows, we get an error:
Microsoft VBScript runtime error.
Object required:'files_table_rows(...)'
If I place this line of code:
Set cell = files_table_rows(row_index)
right before the While loop, cell gets set correctly. The issue is happening inside the While loop, and I don't understand why this is a problem.

Run time error 1004, Application defined or object defined error in excel vbs

I have written vbscript code to add chart in page 1 of excel for which the source is from other sheet of same excel which name is "CL.1.1" but i am getting the above error can any one help what was wrong in my below code.
Sub DispvsTime(Shname)
Sheets("Sheet1").Select
noofsheets = ActiveSheet.ChartObjects.Count
If noofsheets > 0 Then
ActiveSheet.ChartObjects.Select
ActiveSheet.ChartObjects.Delete
End If
Sheets("Sheet1").Pictures.Visible = False
ActiveSheet.Shapes.AddChart(1000, 420, 50, 500).Select
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SetSourceData Source:=Sheets(Shname).Range("G2:H2001")
ActiveChart.SetElement (msoElementChartTitleAboveChart)
ActiveChart.ChartTitle.Text = "Displacement VS Time"
End Sub
here shname is name of the sheet where data is picked.
Can any one help me to find out the bug inside the code to get this error ?
If the sheet name is Shname then place it around quotation marks, if it is a variable name, which holds the sheet name, then ignore this post :P
Sheets("Shname")
If your code is really VBScript as you say, and not VBA as it looks like, then there are several issues:
Unlike VBA you cannot use objects like ActiveSheet or ActiveChart directly in VBScript. You need a reference to these objects, usually the application object:
Set xl = CreateObject("Excel.Application")
xl.ActiveSheet.Name = "foo"
VBScript doesn't know about Excel/Office constants like xlXYScatterSmoothNoMarkers or msoElementChartTitleAboveChart, so you have to either use literal values or define those constants yourself:
Const xlXYScatterSmoothNoMarkers = 73
You can't use named arguments like Source:=... in VBScript:
xl.ActiveChart.SetSourceData xl.Sheets(Shname).Range("G2:H2001")
See here for a more detailed explanation of the differences between VBA and VBScript.

Resources