I have created an array to store some excel cell addresses, but while running through a portion of the array with a For Loop (because the values are in order for that portion of the data and its easier than doing each one at a time), but I get an error at line 22,(saData(i,1) = "D" count), right at the "count" variable but I cant figure out why.
'LOADING EXCEL CELL ADDRESS INTO INPUT ARRAY
saData(0,1) = "C3"
saData(1,1) = "F3"
saData(2,1) = "C4"
saData(3,1) = "F4"
saData(4,1) = "F6"
saData(5,1) = "C7"
saData(6,1) = "F7"
saData(7,1) = "C8"
saData(8,1) = "C9"
saData(9,1) = "F9"
saData(10,1) = "C11"
saData(12,1) = "F11"
saData(13,1) = "C13"
saData(14,1) = "F13"
Dim count : count = 16
For i = 15 to 54
saData(i,1) = "D" count
count = count + 1
next'
saData(55,1) = "G59"
saData(56,1) = "F60"
saData(57,1) = "B64"
saData(58,1) = "E64"
For i = 0 to 59
Msgbox saData(i,1)
next
Just try concatenating saData(i,1) = "D"&count
Related
I have completed the main objective of dividing the day into "cycles". Now, I am having trouble with creating a "sub cycle" within each zone that is defined. I basically am trying to take a cycle (sesionTime1) and split that at 0.38 and 0.62 be it with a vertical line that only goes from the overall session high/low, or just create another box where the start of the box is at the 0.38 and the end of the box is at 0.62. I have tried defining sessionTime1 * 0.38, but thats not working for me. And, using bar_indez(X) only focuses on the bar movement which will change as the timeframe on chart is changed.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © hitmanict
//#version=5
indicator("AMD", overlay=true)
//Get boolean input value (on/off buttons)
//Accumulation
inputAcc = input.bool(title = "Accumulation", defval = true, tooltip = "Turn On/Off Accumulation & Select Color", inline = "1", group = "Accumulation")
inputAccColor = input.color(title = "Box", defval = color.new(#4caf50, 90), inline = "2", group = "Accumulation")
InputAccBorder = input.color(title = "Border", defval = color.rgb(0, 0, 0, 95), inline = "2", group = "Accumulation")
inputAccSub = input.bool(title = "Accumulation Fractal", defval = true, group = "Accumulation")
sessionTime1 = input.session("1845-0330", title = "Session Time")
sessionZone1 = input.string("GMT-5", title = "Session Time Zone")
//Manipulation
inputMan = input.bool(title = "Manipulation", defval = true, tooltip = "Turn On/Off Manipulation & Select Color", inline = "3", group = "Manipulation")
inputManColor = input.color(title = "Box", defval = color.new(#ffcc80,80), inline = "4", group = "Manipulation")
InputManBorder = input.color(title = "Border", defval = color.rgb(0, 0, 0, 95), inline = "4", group = "Manipulation")
sessionTime2 = input.session("0330-0900", title = "Session Time")
sessionZone2 = input.string("GMT-5", title = "Session Time Zone")
//Distribution
inputDistro = input.bool(title = "Distribution", defval = true, tooltip = "Turn On/Off Distribution & Select Color", inline = "5", group = "Distribution")
inputDistColor = input.color(title = "Box", defval = color.new(#2962ff,95), inline = "6", group = "Distribution")
InputDistBorder = input.color(title = "Border", defval = color.rgb(0, 0, 0, 95), inline = "6", group = "Distribution")
sessionTime3 = input.session("0900-1845", title = "Session Time")
sessionZone3 = input.string("GMT-5", title = "Session Time Zone")
//InSession() returns 'true' when the current bar happens inside
//the specified session, corrected for the given time zone (optional).
//Returns 'false' when the bar doesn't happen in that time period,
//or when the chart's time frame is 1 day or higher.
InSession1(sessionTime1, sessionZone1=syminfo.timezone) => not na(time(timeframe.period, sessionTime1, sessionZone1))
InSession2(sessionTime2, sessionZone1=syminfo.timezone) => not na(time(timeframe.period, sessionTime2, sessionZone2))
InSession3(sessionTime3, sessionZone1=syminfo.timezone) => not na(time(timeframe.period, sessionTime3, sessionZone3))
//See if the session is currently active and just started
inSession1 = InSession1(sessionTime1, sessionZone1) and timeframe.isintraday
session1Start = inSession1 and not inSession1[1]
inSession2 = InSession2(sessionTime2, sessionZone2) and timeframe.isintraday
session2Start = inSession2 and not inSession2[1]
inSession3 = InSession3(sessionTime3, sessionZone3) and timeframe.isintraday
session3Start = inSession3 and not inSession3[1]
//Create variables
var session1HighPrice = 0.0
var session1LowPrice = 0.0
var session2HighPrice = 0.0
var session2LowPrice = 0.0
var session3HighPrice = 0.0
var session3LowPrice = 0.0
//When a new session starts, set high/low to the data of the bar in the session.
if session1Start
session1HighPrice := high
session1LowPrice := low
if session2Start
session2HighPrice := high
session2LowPrice := low
if session3Start
session3HighPrice := high
session3LowPrice := low
//Else, during the session, track the highest high and lowest low
else if inSession1
session1HighPrice := math.max(session1HighPrice, high)
session1LowPrice := math.min(session1LowPrice, low)
else if inSession2
session2HighPrice := math.max(session2HighPrice, high)
session2LowPrice := math.min(session2LowPrice, low)
else if inSession3
session3HighPrice := math.max(session3HighPrice, high)
session3LowPrice := math.min(session3LowPrice, low)
//Create persistent variable for the box identifier
var box session1Box = na
var box session2Box = na
var box session3Box = na
//When a session begins, make a new box for that session
if session1Start
session1Box := inputAcc ? box.new(left=bar_index, top = na, right = na, bottom = na, bgcolor = inputAccColor, border_color = InputAccBorder) : na
if session2Start
session2Box := inputMan ? box.new(left=bar_index, top = na, right = na, bottom = na, bgcolor = inputManColor, border_color = InputManBorder) : na
if session3Start
session3Box := inputDistro ? box.new(left=bar_index, top = na, right = na, bottom = na, bgcolor = inputDistColor, border_color = InputDistBorder) : na
//During the session, update that session's existing box
if inSession1
box.set_top(session1Box, session1HighPrice)
box.set_bottom(session1Box, session1LowPrice)
box.set_right(session1Box, bar_index + 1)
if inSession2
box.set_top(session2Box, session2HighPrice)
box.set_bottom(session2Box, session2LowPrice)
box.set_right(session2Box, bar_index + 1)
if inSession3
box.set_top(session3Box, session3HighPrice)
box.set_bottom(session3Box, session3LowPrice)
box.set_right(session3Box, bar_index + 1)
*//Sub AMD Section*
//Create persistent variable for the sub box identifier
var box session1BoxSub = na
var box session2BoxSub = na
var box session3BoxSub = na
if session1Start
session1BoxSub := inputAcc == inputAccSub ? box.new(left = bar_index, top = na, right = na, bottom = na, bgcolor = color.rgb(0, 187, 212, 100), border_color = color.rgb(171, 173, 177), border_style = line.style_dotted, border_width = 2) : na
if inSession1
box.set_top(session1BoxSub, session1HighPrice)
box.set_bottom(session1BoxSub, session1LowPrice)
box.set_right(session1BoxSub, bar_index + 1)
I am attempting this addition at the very bottom unde3r SUB AMD SECTION. Any help/guidance is greatly appreciated.
I leveled up my character and got some items, when i rejoined, it didn't load my previous data, It gave me level 0 and didn't load any items (it didn't give any output for level problem, but it gave this output for item problem: 'for' limit must be a number), but PLD.ItemNumber is a number, because It is from "ItemNumber" variable in the saving function. How to fix it? Code:
local DataStoreService = game:GetService("DataStoreService");
local PD = DataStoreService:GetDataStore("PlayerData");
function SaveData(Player)
local TableSave = {};
TableSave.Level = Player.PlayerData.Stats.Level.Value;
local TableItems = {};
local ItemNumber = 0;
for i,v in pairs(Player.PlayerData.Items:GetChildren()) do
ItemNumber = ItemNumber + 1;
TableItems["Item"..ItemNumber]={};
local TI = TableItems["Item"..ItemNumber];
TI.ItemName = v.Name;
TI.Level = v.Level.Value;
TI.Damage = v.Damage.Value;
end
table.insert(TableSave,TableItems);
TableSave.ItemNumber = ItemNumber;
PD:SetAsync(Player.userId,TableSave);
end
function LoadData(Player)
local success, err = pcall(function()
PLD = PD:GetAsync(Player.userId);
end)
if success then
Player.PlayerData.Stats.Level.Value = PLD.Level;
for i = 1,PLD.ItemNumber do
local CurrentItem = Instance.new("Folder");
CurrentItem.Name = PLD[1]["Item"..i].ItemName;
local Lv = Instance.new("IntValue");
Lv.Name = "Level";
Lv.Value = PLD[1]["Item"..i].Level;
Lv.Parent = CurrentItem;
local Dm = Instance.new("IntValue");
Dm.Name = "Damage";
Dm.Value = PLD[1]["Item"..i].Damage;
Dm.Parent = CurrentItem;
CurrentItem.Parent=Player.PlayerData.Items;
end
else
print("ERROR IN GET ASYNC");
end
end
game.Players.PlayerRemoving:Connect(function(plr)
repeat wait() until plr.PlayerData;
SaveData(plr);
end)
game.Players.PlayerAdded:Connect(function(plr)
repeat wait() until plr.PlayerData;
LoadData(plr);
end)
im writing an app for accountings of small hotel, i'm working with Visual Studio 2013, on OS: windows 10 (Laptop). After finishing the app just published it using publish wizard, then everything was going great till i copied the published files to another computer contains OS: Windows 7 SP1, the app worked successfully but with a little changes in form design and while preview reports printing.
Here's two pictures to explain what is exactly the problem...
If anyone could explain what's going on and what to do to solve this issue would be respected.
Here's my class which contains printpreviewcontrol code:
Private mRow As Integer = 0
Private newpage As Boolean = True
Private Sub PrintDocument1_PrintPage(sender As Object, e As PrintPageEventArgs) Handles PrintDocument1.PrintPage
Try
Dim font36 = New Font("Playball", 36, FontStyle.Regular)
Dim font8 = New Font("Lora", 8, FontStyle.Regular)
Dim font20 = New Font("Lora", 20, FontStyle.Underline)
Dim font16 = New Font("Lora", 16, FontStyle.Regular)
e.Graphics.DrawString("Riviera Beach Chalets", font36, Brushes.Black, New Rectangle(150, 25, 800, 100))
e.Graphics.DrawString("Accounting Reports", font20, Brushes.Black, New Rectangle(650, 45, 300, 50))
e.Graphics.FillRectangle(Brushes.MistyRose, New Rectangle(101, 741, 19, 19))
e.Graphics.DrawString("Accommondation Revenue or Beach Revenue or CoffeeShop Revenue is 0", font8, Brushes.Black, New Rectangle(125, 745, 500, 30))
e.Graphics.DrawString("Amount Received Total :", font16, Brushes.Black, New Rectangle(570, 735, 500, 50))
e.Graphics.DrawString(Report_Database.reporttot, font16, Brushes.Black, New Rectangle(850, 735, 500, 50))
' sets it to show '...' for long text
Dim fmt As StringFormat = New StringFormat(StringFormatFlags.LineLimit)
fmt.LineAlignment = StringAlignment.Center
fmt.Trimming = StringTrimming.EllipsisCharacter
Dim y As Int32 = e.MarginBounds.Top
Dim rc As Rectangle
Dim x As Int32
Dim h As Int32 = 0
Dim row As DataGridViewRow
' print the header text for a new page
' use a grey bg just like the control
If newpage Then
row = Report_Database.DataGridView1.Rows(mRow)
x = 50
For Each cell As DataGridViewCell In row.Cells
' since we are printing the control's view,
' skip invidible columns
If cell.Visible Then
rc = New Rectangle(x, y, cell.Size.Width, cell.Size.Height)
e.Graphics.FillRectangle(Brushes.LightGray, rc)
e.Graphics.DrawRectangle(Pens.Black, rc)
' reused in the data pront - should be a function
Select Case Report_Database.DataGridView1.Columns(cell.ColumnIndex).DefaultCellStyle.Alignment
Case DataGridViewContentAlignment.BottomRight,
DataGridViewContentAlignment.MiddleRight
fmt.Alignment = StringAlignment.Far
rc.Offset(-1, 0)
Case DataGridViewContentAlignment.BottomCenter,
DataGridViewContentAlignment.MiddleCenter
fmt.Alignment = StringAlignment.Center
Case Else
fmt.Alignment = StringAlignment.Near
rc.Offset(2, 0)
End Select
e.Graphics.DrawString(Report_Database.DataGridView1.Columns(cell.ColumnIndex).HeaderText,
Report_Database.DataGridView1.Font, Brushes.Black, rc, fmt)
x += rc.Width
h = Math.Max(h, rc.Height)
End If
Next
y += h
End If
newpage = False
' now print the data for each row
Dim thisNDX As Int32
For thisNDX = mRow To Report_Database.DataGridView1.RowCount - 1
' no need to try to print the new row
If Report_Database.DataGridView1.Rows(thisNDX).IsNewRow Then Exit For
row = Report_Database.DataGridView1.Rows(thisNDX)
h = 0
' reset X for data
x = 50
' print the data
For Each cell As DataGridViewCell In row.Cells
If cell.Visible Then
rc = New Rectangle(x, y, cell.Size.Width, cell.Size.Height)
' SAMPLE CODE: How To
' up a RowPrePaint rule
If Val(row.Cells(2).Value) = 0 Or Val(row.Cells(3).Value) = 0 Or Val(row.Cells(4).Value) = 0 Then
Using br As New SolidBrush(Color.MistyRose)
e.Graphics.FillRectangle(br, rc)
End Using
End If
e.Graphics.DrawRectangle(Pens.Black, rc)
Select Case Report_Database.DataGridView1.Columns(cell.ColumnIndex).DefaultCellStyle.Alignment
Case DataGridViewContentAlignment.BottomRight,
DataGridViewContentAlignment.MiddleRight
fmt.Alignment = StringAlignment.Far
rc.Offset(-1, 0)
Case DataGridViewContentAlignment.BottomCenter,
DataGridViewContentAlignment.MiddleCenter
fmt.Alignment = StringAlignment.Center
Case Else
fmt.Alignment = StringAlignment.Near
rc.Offset(2, 0)
End Select
e.Graphics.DrawString(cell.FormattedValue.ToString(),
Report_Database.DataGridView1.Font, Brushes.Black, rc, fmt)
x += rc.Width
h = Math.Max(h, rc.Height)
End If
Next
y += h
' next row to print
mRow = thisNDX + 1
If y + h > e.MarginBounds.Bottom Then
e.HasMorePages = True
' mRow -= 1 causes last row to rePrint on next page
newpage = True
Button1.Enabled = True
Button4.Enabled = True
If mRow = Report_Database.DataGridView1.RowCount Then
e.HasMorePages = False
Exit Sub
End If
Return
End If
Next
Catch ex As Exception
MsgBox(ex.ToString, MsgBoxStyle.Critical)
End Try
I have a EXGrid in a form and want to add button to a cell that either say "Edit" and "Remove", or Have icons for the two. Here is the code I have so far.
With grdGrade
.BeginUpdate
'.DataSource = objCo.DAL.Connection.Execute(sql)
.DefaultItemHeight = 21
.TreeColumnIndex = -1
.MarkSearchColumn = False
.FullRowSelect = exItemSel
.DrawGridLines = exAllLines
.SortOnClick = exNoSort
.BackColorHeader = grdGrade.BackColor
.Appearance = Flat
.BackColorAlternate = Me.BackColor
.SelBackColor = RGB(224, 224, 224)
.SelForeColor = vbBlack
.UseTabKey = True
.Font = Me.Font
.EndUpdate
End With
Set col = grdGrade.Columns.Add("Actions")
col.AllowDragging = False
col.Width = grdGrade.Width * 0.05
col.Editor.AddButton "Edit", , 0
col.Editor.AddButton "Remove", , 0
col.Editor.EditType = ButtonType
Thanks so much for all your help.
I finally got it. When loading the grid I used:
Me.grdGrade.Items.CellValue(h, "Actions") = " Edit "
Me.grdGrade.Items.CellHasButton(h, "Actions") = True
s = Me.grdGrade.Items.SplitCell(h, "Actions")
Me.grdGrade.Items.CellValue(0, s) = " Remove "
Me.grdGrade.Items.CellHasButton(0, s) = True
and it works like a charm
I can sort a table with two pieces of information (the name and a second piece, such as age) with the following code:
t = {
Steve = 4,
Derek = 1,
Mike = 5,
Steph = 10,
Mary = 7,
Danny = 2
}
function pairsByKeys (t,f)
local a = {}
for x in pairs (t) do
a[#a + 1] = x
end
table.sort(a,f)
local i = 0
return function ()
i = i + 1
return a[i], t[a[i]]
end
end
for a,t in pairsByKeys (t) do
print (a,t)
end
Result:
Danny 2
Derek 1
Mary 7
Mike 5
Steph 10
Steve 4
I have a scenario where at a convention each person's name tag contains a barcode. This barcode, when scanned, enters four pieces of information about each person into a table database. This database is made up of the following pieces:
t = {
{name = "Mike", addr = "738 Rose Rd", age = 30, phone = "333-902-6543"}
{name = "Steph", addr = "1010 Mustang Dr", age = 28, phone = "555-842-0606"}
{name = "George", addr = "211 Glass St", age = 34, phone = "111-294-9903"}
}
But how would I change my code to sort all four entries (name, addr, age, phone) by age and keep all variables in line with one another?
I've been trying to experiment and am getting the hang of sorting a table by pairs and have a better idea how to perform table.sort. But now I want to take this another step.
Can I please receive some help from one of the programming gurus here?! It is greatly appreciated guys! Thanks!
You could use the age as the key of your table:
t = {
[30] = {name = "Mike", addr = "738 Rose Rd", age = 30, phone = "333-902-6543"},
[28] = {name = "Steph", addr = "1010 Mustang Dr", age = 28, phone = "555-842-0606"},
[34] = {name = "George", addr = "211 Glass St", age = 34, phone = "111-294-9903"},
}
function pairsByKeys (t,f)
local a = {}
for x in pairs (t) do
a[#a + 1] = x
end
table.sort(a,f)
local i = 0
return function ()
i = i + 1
return a[i], t[a[i]]
end
end
for a,t in pairsByKeys (t) do
print (t.name, t.addr, t.age, t.phone)
end
EDIT
Otherwise, if you don't want to change the structure of t, you could change your iterator generating function to keep track of the indexing:
t = {
{name = "Mike", addr = "738 Rose Rd", age = 30, phone = "333-902-6543"},
{name = "Steph", addr = "1010 Mustang Dr", age = 28, phone = "555-842-0606"},
{name = "George", addr = "211 Glass St", age = 34, phone = "111-294-9903"},
}
function pairsByAgeField(t,f)
local a = {}
local index = {}
for _, x in pairs(t) do
local age = x.age
a[#a + 1] = age
index[age] = x
end
table.sort(a,f)
local i = 0
return function ()
i = i + 1
return a[i], index[a[i]]
end
end
for a,t in pairsByAgeField(t) do
print (t.name, t.addr, t.age, t.phone)
end
Of course this makes pairsByAgeField less generally applicable than your original pairsByKeys (it assumes that the table being iterated has a given structure), but this is not a problem if you often have to deal with tables such as t in your application.