|
|
I think what you need to research is the topic of concurrency.
One way to implement this is to have a Modify Date on the primary record.
1) Read the table entry along with the modify date/time.
2) When updating the database, compare the original date/time with the value currently stored, if the date/time has not been changed, then it is OK to perform your update. (Rollback)
During your update you would set the modify date/time to the current date/time. (GetDate() )
Something like that.
|
|
|
|
|
I am sure this is not the best format to ask this question/ have this general discussion.
My project is at the barebones, working on a lot of the basics at the moment. The plan is to have a game completely ran on a userform.
Really the only thing I have kind of figured out is the the key logging to track when the space bar, left, right, up, down arrow keys have been pressed. I have only figured out how to do that if a textbox is the focus. Not the happiest with that at moment. Any thoughts on this is appreciated.
I have done a ton of research to see what is currently out there. A majority of the code I find is ran on a spreadsheet, which becomes the base/map. Taking away the spreadsheet leaves my google searches with not many results.
Something I have thought of is having a userform with multiple textboxes like a spreadsheet. Each textbox would be like one cell on a spreadsheet. Problem with this is that I don't think that would do well once trying too get more advance with the game.
The thing that seems like it will be key is keeping track of the pixels location of every object and creating the game logic from there.
The object of the game really isn't the focus right now. To give an end game for my first problem/"curiousosity on how others would go about it" lets say the game is to have a character dodge incoming missles/objects that would come from any direction straight across the board.
I would post my code but it really isn't much at the moment.
1. Please don't respond with something like "why would you do this in vba" or anything like that. I am well aware that there other languages that would better fit this.
2. Sorry for everything being "scatter brained" this is my first time posting a question after about 2 years of doing multiple projects using vba.
3. If there is a better site or resource to use for what I am trying to do please let me know.
There isn't any direct questions, more so looking to get thoughts and opinons on anything I put out there. Appreciate any feedback!
|
|
|
|
|
In other VB Windows Forms implementations, the KeyDown/KeyUp events on your Form will only work if the Form has the focus. If the Excel sheet has the focus, they will not work.
Also, in order to get those events to work when any control on the Form has the focus, the KeyPreview property on the Form must also be set to true, though, it appears that this doesn't even exist in Excel VBA.
Basically, without a working KeyPreview property, you cannot do what you appear to want to do.
|
|
|
|
|
First, Thank you for engaging in the conversation!
My idea at the moment is to have the spreadsheet hidden as soon as the userform is initiated. That could be from a command button or from the moment excel loades/macros are enabled.
I am thinking that a full screen userform, with an api to keep the userform always on top. Then (idk if this is a thing) an api to keep the userform always in focus?
From there keep a textbox always in focus (assuming hidden or not visible probably) to keep the ability of key logging.
If this is the best road to keep the Ability of logging the arrow keys pressed, maybe have two objects above and below the textbox in the zorder to force the focus back to main key logging textbox?
Any ideas, thoughts, or better work around that you can think of?
|
|
|
|
|
In Excel VBA, there is no such thing as "Always on top", and in Windows, there is no such thing as "Always has focus".
Windows is a shared system. Your app has to play nice with everything else, including the ability to lose focus to another app at any time, no matter which environment you write code in.
The limitations of VBA are going to fight you all the way on this.
|
|
|
|
|
I am working in VB6 project. Need to generate XML file. How to do that? Thanks for the help
|
|
|
|
|
|
Good evening everyone.
I'm trying to implement a user control's drag & drop and would like all control to follow mouse movements. However the method does not allow me to move the entire control, but displays the mouse arrow with the classic drag & drop icon.
How can I solve this problem in Vb.net
modified 8-Jun-20 1:33am.
|
|
|
|
|
|
Like Drag Multiple Controls with Shadows Effects[^] ?
Alternatively (but harder) is to draw your controls to a canvas, and use that image as the cursor.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Yes, correct. This is the method I seek.
Thanks a lot!
|
|
|
|
|
You're welcome
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I have two tables: one as master (Ricetta) the second IngedientiRicetta) as details, in which the details table as a key field that has 'Identity (1,1) ON'.
When I use them on sql 2019 developer server all things run well.
When I use then SQL 2019 Express, I receive the following error:
'When IDENTITY_INSERT is OFF it is not possible to insert an explicit value for the ldentity column in the 'DataTable' IngedientiRicetta,
in System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUp datedEventArgs rowUpdatedEvent, BatchCommandlnfo0 batchCommands, lnt32 commandCount)
in System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdated EventArgs rowUpdatedEvent, BatchCommandlnfo0 batchCommands, lnt32 commandCount)
in System.Data.Common.DbDataAdapter.Update(DataRowO dataRows, DataTableMapping tableMapping)
in System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
in System.Data.Common.DbDataAdapter.Update(DataTable dataTable) in RicetteVB.RicetteDataSetTableAdapters.lngedientiRicettaTableAdapter.U pdate(lngedientiRicettaDataTable dataTable)
in RicetteVB.Ricette.RicettaBindingNavigatorSaveltem_ Click(Object sender, EventArgs e)"
I will appreciate any help to understand the problem.
Thans
Roberto
|
|
|
|
|
You're trying to insert a value into an identity column. We can't tell you why, or how to fix it, since we can't see your code.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Iam sending the code tha is - for me - involved
Private Sub Ricette_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
DS = New RicetteDataSet
Me.IngedientiRicettaDataGridView.Visible = True
If RiceID = 0 Then
TaRicette.Fill(DS.Ricetta)
Else
TaRicette.FillBy1(DS.Ricetta, RiceID)
RiceID = 0
End If
TaIngredienti.Fill(DS.Ingedienti)
TaIngredientiRicetta.Fill(DS.IngedientiRicetta)
TaUm.Fill(DS.Um)
TaTipoCottura.Fill(DS.TipoCottura)
TaCategoria.Fill(DS.Categorie)
'------------------------------------------------------------------------
IngredientiBindingSource.DataMember = "Ingedienti"
IngredientiBindingSource.DataSource = DS
TipoCotturaBindingSource.DataSource = DS
TipoCotturaBindingSource.DataMember = "TipoCottura"
CategorieBindingSource.DataMember = "Categorie"
CategorieBindingSource.DataSource = DS
UmBindingSource.DataSource = DS
UmBindingSource.DataMember = "Um"
'------------------------------------------------------------------------
Me.RicettaBindingSource.DataSource = DS
Me.RicettaBindingSource.DataMember = "Ricetta"
Me.RicettaBindingSource.Position = pos
'Me.RicettaBindingSource.MoveLast()
IngredientiRicettaBindingSource.DataSource = RicettaBindingSource
IngredientiRicettaBindingSource.DataMember = "FK_IngedientiRicetta_Ricetta"
'------------------------------------------------------------------------
Catch nhex As InvalidOperationException
MsgBox(nhex.Message)
Catch ex As Exception
Err(ex, "Form Load" & Me.Name)
End Try
End Sub
'----- Saving IngedientiRicettaDatagridView to IngedientiRicetta SQL Table-----
Private Sub BtnSalvaIngredienti_Click(sender As Object, e As EventArgs) Handles BtnSalvaIngredienti.Click
Try
Validate()
RicettaBindingSource.EndEdit()
CategorieBindingSource.EndEdit()
UmBindingSource.EndEdit()
TipoCotturaBindingSource.EndEdit()
IngredientiBindingSource.EndEdit()
IngredientiRicettaBindingSource.EndEdit()
TableAdapterManager.UpdateAll(DS)
'TaIngredientiRicetta.Update(DS.IngedientiRicetta)
Catch nhex As InvalidOperationException
MsgBox(nhex.Message)
Catch ex As Exception
Err(ex, Name)
End Try
End Sub
'-----------------------------------------------------
'Adding new row to IngedientiRicettaDataGridView
'-----------------------------------------------------
Private Sub IngedientiRicettaDataGridView_DefaultValuesNeeded(sender As Object, e As DataGridViewRowEventArgs) Handles IngedientiRicettaDataGridView.DefaultValuesNeeded
Try
With e.Row
.Cells("IngredienteRicettaQtaDataGridViewTextBoxColumn").Value = 0
.Cells("IngredienteNome").Value = String.Empty
.Cells("IngredienteRicettaNoteDataGridViewTextBoxColumn").Value = String.Empty
End With
Catch ex As Exception
Err(ex, Name)
End Try
End Sub
thing that is strange for me:
in the dataset the constraint between 'Ricetta' and 'IngedientiRicetta' is:
INSERT or UPDATE= None
DELETE=None
While in SQL we have
INSERT or UPDATE=Cascade
DELETE = Cascade
In any case I don't give a value to IngedientiRicettaID (key and identity)
Also in datagridview is not added as column.
But why all is good in one SQL server (developer) and wrong in another server (SQL EXPRESS)?
NOTE:The bound IngedientiDataGridView with columns has been created at Design Time
Thanks
|
|
|
|
|
hello everybody.
i have drawn up a userform in excel vba adding either a combobox and a checkbox.
after customizing the outline box sizes, in combobobx the arrow drop button has been down sized turning to be very tiny and in check box the blank tick square has been down sized as well becoming very small too. i can t find any property to adjust that size. any tip? thanks
|
|
|
|
|
What I have tried:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
'Timer1 with intervel 1000ms
Dim OneSecPulse As Boolean
Dim Data As Double
Dim Total As Double
Dim Average As Double
Dim Counts As Integer
OneSecPulse = True
If OneSecPulse = True Then
Counts = Counts + 1
Total = Total + Data
OneSecPulse = False
End If
If Counts = 60 Then
Average = Total / 60
Total = 0
Counts = 0
End If
End Sub
|
|
|
|
|
|
As mentioned in your other post, just total and divide. What's wrong?
My guess is Counts != 60. But all you have to do is debug. Very simple.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
I'm trying to convert some c# code that makes an API function call that has a parameter to a callback. I get a compiler error regarding the "Log" parameter in the call in the frmMain_Load function. How do I define things so that I satisfy the call to this function. Any help is greatly appreciated.
The c# code I'm trying to convert is:
public static IPublicClientApplication PublicClientApp { get; private set; }
static App()
{
PublicClientApp = PublicClientApplicationBuilder.Create(ClientId)
.WithB2CAuthority(AuthoritySignUpSignIn)
.WithLogging(Log, LogLevel.Verbose, false)
.Build();
}
private static void Log(LogLevel level, string message, bool containsPii)
{
string logs = ($"{level} {message}");
StringBuilder sb = new StringBuilder();
sb.Append(logs);
File.AppendAllText(System.Reflection.Assembly.GetExecutingAssembly().Location + ".msalLogs.txt", sb.ToString());
sb.Clear();
}
I've converted the code as follows:
Private Async Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PublicClientApp = PublicClientApplicationBuilder.Create(ClientId).WithB2CAuthority(AuthoritySignUpSignIn).WithLogging(Log, LogLevel.Verbose, False).Build
End Sub
Function Log(ByVal level As LogLevel, Message As String, ByVal containsPii As Boolean)
Dim logs As String = ($"{level} {Message}")
Dim sb As StringBuilder = New StringBuilder()
sb.Append(logs)
File.AppendAllText(System.Reflection.Assembly.GetExecutingAssembly().Location & ".msalLogs.txt", sb.ToString())
sb.Clear()
End Function
|
|
|
|
|
Try adding AddressOf :
PublicClientApp = PublicClientApplicationBuilder.Create(ClientId).WithB2CAuthority(AuthoritySignUpSignIn).WithLogging(AddressOf Log, LogLevel.Verbose, False).Build()
I don't like either version of the Log function - why does it create a StringBuilder , add one string, and then convert it back to a string? Unless there's other code in there which you haven't shown, you can just use:
private static void Log(LogLevel level, string message, bool containsPii)
{
string logs = $"{level} {message}";
File.AppendAllText(System.Reflection.Assembly.GetExecutingAssembly().Location + ".msalLogs.txt", logs);
}
Private Shared Sub Log(ByVal level As LogLevel, ByVal message As String, ByVal containsPii As Boolean)
Dim logs As String = $"{level} {message}"
File.AppendAllText(System.Reflection.Assembly.GetExecutingAssembly().Location + ".msalLogs.txt", logs)
End Sub
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks Richard. That solved it. Regarding the Stringbuilder, I simply used the online c# to vb.net code converter to get me started. I usually then go back and simplify. I knew the Log routine was insignifcant to problem I was having.
Sorry for posting in the wrong forum. I thought I had picked the VB.net forum. My Mistake. Thanks again.
|
|
|
|
|
I have upgraded my Visual Studio to 2019 but some of the statement can be ran on old version but failed in the new version of 2019 which is using crystal report as following :
Dim DA As New SqlDataAdapter(strsql2, Connection)
Dim DS As New DataSet
Dim strReportName As String
DA.Fill(DS)
Dim rptDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
rptDocument.Load(strReportPath)
rptDocument.SetDataSource(DS.Tables(0))
WHERE - The rptDocument.SetDataSource(DS.Tables(0)) is not working and always prompted with error of - Failed to load database information.
i spent days and so frustrated about this issue with no idea on how the error occurred, kindly please give me some advise, thx a lots......
Brs
George
|
|
|
|
|
Check the SQL command, and the dataconnectionstring. Try them both in a separate new project, or post those here.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|