|
Dave Kreskowiak wrote: It's already going to be activated. You have to
use the Process class to start Paint, then you call the WaitForInputIdle method on it which will block your code until
Paint starts and is ready for input. Then you can use SendKeys. The problem with SendKeys is what if the user
clicks on some other app? All the keys you're sending will then go to that
application, not Paint...
Yes, I am using VB6 on Windows XP.
The focus does not go to Paint. AppActivate also does not do anything either with the name or with the process number.
The user is nobody other than me, so there is little risk of the user clicking another window while Paint is doing its job in 1 second or so.
How do I use WaitForInputIdle? Is that some API command?
|
|
|
|
|
THe entire problem is that you Shell Paint and then you immediately try to Activate it or SendKey to it. Well, Paint hasn't started yet, so those operations do nothing because Paint doesn't have a window yet.
You have to wait for Paint to start and show itself before you can do anything else with it.
In VB.NET, this is two lines of code, uising the Process class. In VB6, it's a bunch more. You don't have a Process class and, hence, you don't have WaitForInputIdle either. You have to write this code yourself.
In VB6, you'd launch Paint, then call the Win32 API function OpenProcess to get the process handle, pass that handle to the Win32 function WaitForInputIdle, then call ReleaseProcessHandle on the handle you got. Seems simple enough, right? Try getting the handle to a Process that hasn't completely started yet...
|
|
|
|
|
I am a little novice in VB programming. I am trying to write a program related to Retail sales where I need to move the MRP to other fields whenever the MRP changes. I have three fields which I intend to update as and when MRP Changes. So the first time the MRP Changes the old MRP will move to MRP1 field. Subsequently to MRP2 and MRP3 field. Next time it should again update MRP1. Can anybody help me on how to do this using SQL updates. I am using VS2008 with MySQL.
|
|
|
|
|
You're going to have to confirm what your database schema is laid out like.
From the sounds of it, you're doing it VERY wrong. You should not have columns in the same table, labeled MRP, MRP1, MRP2, ... and moving the data from column to column. This results in having only a limited, fixed number of updates possible.
|
|
|
|
|
Hi Dave
Thanks for the reply. The Database schema is as follows:
Prodcode Varchar(15)
MRP Double(15,2)
MRP1 Double(15,2)
MRP2 Double(15,2)
MRP3 Double(15,2)
I actually did not understand why you say that the updates will limited. I can understand that the information with respect to MRP changes will be limited to 3 + current. This is ok with me. I don't want to create another table to keep this information as the requirement of keeping the details of MRP change will be enough with a level of 3. Also since I am dealing with FMCG products, and since the rate changes are quite frequent, with huge number of SKUs, I don't want to create another table and utilize additional disk space.
|
|
|
|
|
It's not the correct way of doing this, but, it's your system...
What you lose doing it your way is the ability to roll back any mistakes. History values will be lost if your updates exceed 3 and you try to roll it back. Also, if the user makes a mistake and hits your UPDATE button twice (if not handled properly!), say, in a web app, you could commit the same change to the record more than once and not be able to roll it back.
It's possible to do in a single SQL UPDATE statement. From my feeble memory...
UPDATE yourTable
SET
MRP = @parameterNewValue,
MRP1 = MRP,
MRP2 = MRP1,
MRP3 = MRP2
WHERE Id = @parameterRecordId
|
|
|
|
|
Hi Dave
Thank you so much for the reply. I agree that this is not the correct way of doing it but this is what is the requirement. I know that by keeping a separate table I will not only have the benefit of rollback to any times backward but also I can produce many important reports like price change frequencies, % price changes etc.
Thanks again
|
|
|
|
|
Yeah, you can also do "many important reports" by doing it the correct way. Sure, the SQL is a little more complicated, but it's a LOT safer for your data.
|
|
|
|
|
What you should be doing (as Dave implied) is redesign your table structure so there is 1 MRP field on your product table and a related table containing the history of the MRPs
lnkProductMRP
ProductID int
MRP Double(15,2) (why is this 2 decimal places and not an int)
Modified DateTime - when it was changed
ModifiedBy varchar(##) - who did the deed
Reason varchar(###) - Why the change of MRP
This retains your history past 3 events, allows roll back, and records the person and reason for the change.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have been searching the far reaches of the web trying to find a way to import all of my rss feeds into openoffice base. From what I have gathered so far is that it is possible with VBA code but could not find it anywhere. I think this should not be that difficult.
Also, I have been trying to find a way to forward emails to same database. Is there a way to setup a database email address to send mail to? I have already tried to forward the emails to rss feed but that is not without errors.
Please assist me in anyway, thank you.
|
|
|
|
|
Show us some code, for each of the two questions you have. However, e-mails might not be sendt an masse, as some providers have rules on how many can be sendt as a SPAM filter.
|
|
|
|
|
Hello,
I would like to make a duplicate of the currently open document via a VBA macro.
That is, when running the macro, it will use the current active document as source and make a copy of it without saving it to a file.
The current document may be modified (changes were not yet saved to a file), and it could be based on a specific template, with headers/footers/fields.
The new copy, should have an identical content (including headers/footers/fields) as the original, based on the same template but with a new name and not saved to a file yet. (The user may save it later if required)
Is this possible?
Thanks in advance.
-- Ricky Marek (AKA: rbid)
-- "Things are only impossible until they are not" --- Jean-Luc Picard
My articles
|
|
|
|
|
Perhaps something like this will work for you.
Sub CopyDoc()
Dim sourcedoc As Document
Set sourcedoc = Application.ActiveDocument
Dim newdoc As Document
Set newdoc = Application.Documents.Add(Template:=sourcedoc.AttachedTemplate.FullName, Visible:=True)
sourcedoc.Range.Copy
newdoc.Range.Paste
sourcedoc.Activate
Set sourcedoc = Nothing
Set newdoc = Nothing
End Sub
|
|
|
|
|
I have been working on a minecraft (game) launcher and so far everything is going good. But I want it to do something more.. like install different versions. The way the official launcher does it by reading the .json file. Here is an example of one of the json file:
{
"id": "1.6.4",
"time": "2013-09-19T20:52:37+05:00",
"releaseTime": "2013-09-19T20:52:37+05:00",
"type": "release",
"minecraftArguments": "--username ${auth_player_name} --session ${auth_session} --version ${version_name} --gameDir ${game_directory} --assetsDir ${game_assets}",
"libraries": [
{
"name": "net.sf.jopt-simple:jopt-simple:4.5"
},
{
"name": "com.paulscode:codecjorbis:20101023"
},
{
"name": "com.paulscode:codecwav:20101023"
},
{
"name": "com.paulscode:libraryjavasound:20101123"
},
{
"name": "com.paulscode:librarylwjglopenal:20100824"
},
{
"name": "com.paulscode:soundsystem:20120107"
},
{
"name": "argo:argo:2.25_fixed"
},
{
"name": "org.bouncycastle:bcprov-jdk15on:1.47"
},
{
"name": "com.google.guava:guava:14.0"
},
{
"name": "org.apache.commons:commons-lang3:3.1"
},
{
"name": "commons-io:commons-io:2.4"
},
{
"name": "net.java.jinput:jinput:2.0.5"
},
{
"name": "net.java.jutils:jutils:1.0.0"
},
{
"name": "com.google.code.gson:gson:2.2.2"
},
{
"name": "org.lwjgl.lwjgl:lwjgl:2.9.0",
"rules": [
{
"action": "allow"
},
{
"action": "disallow",
"os": {
"name": "osx",
"version": "^10\\.5\\.\\d$"
}
}
]
},
{
"name": "org.lwjgl.lwjgl:lwjgl_util:2.9.0",
"rules": [
{
"action": "allow"
},
{
"action": "disallow",
"os": {
"name": "osx",
"version": "^10\\.5\\.\\d$"
}
}
]
},
{
"name": "org.lwjgl.lwjgl:lwjgl-platform:2.9.0",
"rules": [
{
"action": "allow"
},
{
"action": "disallow",
"os": {
"name": "osx",
"version": "^10\\.5\\.\\d$"
}
}
],
"natives": {
"linux": "natives-linux",
"windows": "natives-windows",
"osx": "natives-osx"
},
"extract": {
"exclude": [
"META-INF/"
]
}
},
{
"name": "org.lwjgl.lwjgl:lwjgl:2.9.1-nightly-20130708-debug3",
"rules": [
{
"action": "allow",
"os": {
"name": "osx",
"version": "^10\\.5\\.\\d$"
}
}
]
},
{
"name": "org.lwjgl.lwjgl:lwjgl_util:2.9.1-nightly-20130708-debug3",
"rules": [
{
"action": "allow",
"os": {
"name": "osx",
"version": "^10\\.5\\.\\d$"
}
}
]
},
{
"name": "org.lwjgl.lwjgl:lwjgl-platform:2.9.1-nightly-20130708-debug3",
"rules": [
{
"action": "allow",
"os": {
"name": "osx",
"version": "^10\\.5\\.\\d$"
}
}
],
"natives": {
"linux": "natives-linux",
"windows": "natives-windows",
"osx": "natives-osx"
},
"extract": {
"exclude": [
"META-INF/"
]
}
},
{
"name": "net.java.jinput:jinput-platform:2.0.5",
"natives": {
"linux": "natives-linux",
"windows": "natives-windows",
"osx": "natives-osx"
},
"extract": {
"exclude": [
"META-INF/"
]
}
}
],
"mainClass": "net.minecraft.client.main.Main",
"minimumLauncherVersion": 4,
"synced": false
}
I wanted to know how to read this (format it) properly. Example the above gets formated as:
-Djava.library.path=[]versions\1.6.4\1.6.4_TagCraftMC -cp []libraries\net\sf\jopt-simple\jopt-simple\4.5\jopt-simple-4.5.jar;[]libraries\com\paulscode\codecjorbis\20101023\codecjorbis-20101023.jar;[]libraries\com\paulscode\codecwav\20101023\codecwav-20101023.jar;[]libraries\com\paulscode\libraryjavasound\20101123\libraryjavasound-20101123.jar;[]libraries\com\paulscode\librarylwjglopenal\20100824\librarylwjglopenal-20100824.jar;[]libraries\com\paulscode\soundsystem\20120107\soundsystem-20120107.jar;[]libraries\org\lwjgl\lwjgl\lwjgl\2.9.0\lwjgl-2.9.0.jar;[]libraries\org\lwjgl\lwjgl\lwjgl_util\2.9.0\lwjgl_util-2.9.0.jar;[]libraries\argo\argo\2.25_fixed\argo-2.25_fixed.jar;[]libraries\org\bouncycastle\bcprov-jdk15on\1.47\bcprov-jdk15on-1.47.jar;[]libraries\com\google\guava\guava\14.0\guava-14.0.jar;[]libraries\org\apache\commons\commons-lang3\3.1\commons-lang3-3.1.jar;[]libraries\commons-io\commons-io\2.4\commons-io-2.4.jar;[]libraries\net\java\jinput\jinput\2.0.5\jinput-2.0.5.jar;[]libraries\net\java\jutils\jutils\1.0.0\jutils-1.0.0.jar;[]libraries\com\google\code\gson\gson\2.2.2\gson-2.2.2.jar;[]versions\1.6.4\1.6.4.jar net.minecraft.client.main.Main --username ~ --session - 0 --version 1.6.4 --gameDir| --assetsDir []assets
where ~ is username
[] and | is the %appdata% folder
I can format it manually using a notepad but this takes a lot of time and the process isn't automated. The above is an argument which needs to be passed in order to make the game run.
Any help regarding this would be appriciated
modified 17-Oct-13 14:29pm.
|
|
|
|
|
For reading or writing JSON in .NET, the best place to start is the JSON.NET[^] library.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Dear sir,
I made a project in Visual basic and sql server table,i made a window form where i placed a data grid, in data grid the header and data populated from database table, but i want to change the datagrid column header (not database table column)and populate the data from table programmatically.
|
|
|
|
|
You change the column headers by aliasing the columns in your SQL statement
eg
SELECT Firstname as Forename, LastName as Surname FROM tblPerson
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
|
You want to use something like:
gridView.Columns("yadayadayada").HeaderText = "UseTheForce"
DisplayIndex is also worth looking at as it will allow you to re-order the columns.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
dear all,
i want to read a dxf and extract entities data for polyline to be used later
i already read the dxf file but i do not have any idea how to extract the required section from it
my code was
Public Sub Dxf_Reader(ByVal file As String)
Dim tag As IO.StreamReader
Dim txtarray As String()
If infile = "" Then Exit Sub
tag = IO.File.OpenText(infile)
txtarray = tag.ReadToEnd().Split(New String(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries))
tag.Close()
End Sub
|
|
|
|
|
|
Apologoes if this the wrong forum – could be in “Database”, or even C# - it’s a bit of a cross-over...
The scenario:
I have a database table holding records of items that are flagged according to various key terms held in another table – eg:
keywords table:
ID – integer
sKeyword – string
There are about a dozen of these, which won’t change, with ID’s from 1 to 12.
items table:
ID – integer
iKeywords – Double
(other fields)
The iKeywords number is calculated simply as the sum of 2 ^ keywords.ID for all relevant keywords. A record may be associated with multiple keywords. Thus it is easy to select records matching keywords criteria, and updating records is similarly easy.
The problem:
Give the iKeyword value of a particular item, find other items which are matched with some or all of the keywords of this record, ordered by the number of matching keywords.
The solution...?
Apart from an obvious brute-force approach, I am sure there must be an elegant algorithm (c# or vb .NET preferably) that can do it.... even better a really smart SQL statement, but that’s probably hoping for too much.
Or maybe I should be approaching the database structure differently?
|
|
|
|
|
Why is your iKeywords field is a double if you only have 12 keywords and they're not going to change? A 16-bit integer (smallint ) would be sufficient.
The design feels wrong; the standard approach would be to have a many-to-many relationship between the keywords and the items:
Keywords: KeywordID [PK], Keyword
Items: ItemID [PK], ...
ItemKeywords: ItemID [PK, FK], KeywordID [PK, FK]
This would lead to a fairly simple solution:
SELECT
B.ItemID,
Count(1) As MatchedKeywordCount
FROM
ItemKeywords As A
INNER JOIN ItemKeywords As B
ON A.KeywordID = B.KeywordID
WHERE
A.ItemID = @ItemToMatch
And
B.ItemID != @ItemToMatch
GROUP BY
B.ItemID
ORDER BY
MatchedKeywordCount DESC
;
With your current implementation (updated to use an integer type for iKeywords ), you can identify matching products using bitwise-AND[^]:
SELECT
...
FROM
Items
WHERE
(iKeywords & @KeywordsToMatch) != 0
;
Counting the number of matching keywords is slightly more complicated. For example:
WITH N0 (X) As
(
SELECT 1
UNION ALL
SELECT 1
),
N1 (X) As
(
SELECT 1
FROM N0 A CROSS JOIN N0 B
),
N2 (X) As
(
SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) - 1
FROM N1 A CROSS JOIN N1 B
),
PowersOfTwo (Value) As
(
SELECT Power(2, X)
FROM N2
),
MatchingItems As
(
SELECT
I.ItemID,
I.iKeywords & @KeywordsToMatch As MatchedKeywords
FROM
Items As I
WHERE
(I.iKeywords & @KeywordsToMatch) != 0
)
SELECT
I.ItemID,
Count(1) As MatchedKeywordCount
FROM
MatchingItems As I
INNER JOIN PowersOfTwo As P
ON (I.MatchedKeywords & P.Value) != 0
GROUP BY
I.ItemID
;
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Many thanks for this - should be enough to get me going!
I used a double only because when I began I wasns't sure of the exact keyword list, so played safe in case there were more. I agree the design "looks wrong" as it is clearly limited to only a relatively small number of keywords. I'll have a play with doing it right!
|
|
|
|
|
Sir Please tell me how to run an external exe in a frame in vb.net... it is possible...
|
|
|
|
|