|
tinmail wrote: I know in SQL server doesn't have the "LIMIT" function.
Not really true.
You could create your dataset with 2 tables (like Dave referred to earlier):
DataSet Orders
Table (top 20 customers)
Table2 (bottom 30 customers).
You would then use a 'Select TOP' and an ORDER BY statement to order the records however you want (maybe combined with a group by) and do the fills.
Top 20 highest
Select top 20 *
From Customers
order by AR Balance
Bottom 30
Select top 30 *
From Customers
order by AR Balance desc
Personally, I would just fill one datatable and use a dataview to filter the rows vs filling two tables.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
hi.
i have been programming for some time with this project here. and sorry. i cannot explain the full use of the project.
here are some of the code : and until now it almost fills 5500 lines.
- - - - -
kpar_holder20 = 0 : kpar_holder21 = 0 : kpar_holder22 = 0 : kpar_holder23 = 0
kpar_holder24 = 0 : kpar_holder25 = 0 : kpar_holder26 = 0 : kpar_holder27 = 0
kpar_holder28 = 0 : kpar_holder29 = 0 : kpar_holder30 = 0 : kpar_holder31 = 0
infbox1.Text = "calculations started"
shuf1 = CStr(TextBox1.Text)
Do While counter5 <= ant1 And CheckBox1.Checked = True
If CheckBox2.Checked = True Then
TextBox7.Text = counter5
End If
Call blandkort_to(shuf1) 'bland kortene
Call to_kind() 'check 2 of a kind OG low/high
Call uds_perc(ant1) 'udregner procent og skifter baggrundsfarve på procent tal.
counter5 = counter5 + 1
Loop
Call result1() 'udskriv resultat til skærm
infbox1.Text = "calculations stopped"
pt1.BackColor = Color.Red : pt2.BackColor = Color.Red : pt3.BackColor = Color.Red
pt4.BackColor = Color.Red : pt5.BackColor = Color.Red : pt6.BackColor = Color.Red
pt7.BackColor = Color.Red : pt8.BackColor = Color.Red : pt9.BackColor = Color.Red : pt10.BackColor = Color.Red
block_p1 = 1 : block_p2 = 1 : block_p3 = 1 : block_p4 = 1 : block_p5 = 1
block_p6 = 1 : block_p7 = 1 : block_p8 = 1 : block_p9 = 1 : block_p10 = 1
End Sub
Sub uds_perc(ByVal ant1) 'udregner procent og skifter baggrundsfarve på procent tal.
p1 = ((counter5 * 100) \ ant1)
If p1 >= 1 And p1 <= 10 And block_p1 = 1 Then
pt1.BackColor = Color.Green
block_p1 = 0
ElseIf p1 >= 11 And p1 <= 20 And block_p2 = 1 Then
pt2.BackColor = Color.Green
'MsgBox("alt ok") '' test command
block_p1 = 0
ElseIf p1 >= 21 And p1 <= 30 And block_p3 = 1 Then
=1= what i don't understand in this code here. is the line =
If CheckBox2.Checked = True Then
TextBox7.Text = counter5
End If
=1= the program do not print counter 5 to textbox.text. and i cannot see whats wrong in the code.
=2= the next i cannot see. is =
If p1 >= 1 And p1 <= 10 And block_p1 = 1 Then
pt1.BackColor = Color.Green
block_p1 = 0
=2= it will not change the backcolor on pt1.
- - - - -
hope anybody can see an error i cannot see.
and i know there are some calls. but they are in the same for. so everything is happening in the same form.
the variables used in this here is :
Public kpar, kpar2, kpar3, kpar4, kpar5, kpar6, kpar7, kpar8, kpar9, kpar10, kpar11 As Integer
Public kpar_holder, kpar_holder1, kpar_holder2, kpar_holder3, kpar_holder4, kpar_holder5, kpar_holder6, kpar_holder7, kpar_holder8, kpar_holder9, kpar_holder10 As Integer
Public kpar12, kpar13, kpar14, kpar15 As Integer
Public kpar16, kpar17, kpar18, kpar19 As Integer
Public kpar20, kpar21, kpar22, kpar23 As Integer
Public kpar24, kpar25, kpar26, kpar27 As Integer
Public kpar28, kpar29, kpar30, kpar31 As Integer
Public kpar_holder12, kpar_holder13, kpar_holder14, kpar_holder15 As Integer
Public kpar_holder16, kpar_holder17, kpar_holder18, kpar_holder19 As Integer
Public kpar_holder20, kpar_holder21, kpar_holder22, kpar_holder23 As Integer
Public kpar_holder24, kpar_holder25, kpar_holder26, kpar_holder27 As Integer
Public kpar_holder28, kpar_holder29, kpar_holder30, kpar_holder31 As Integer
Public shuf1, counter5, p1 As Integer
Public block_p1, block_p2, block_p3, block_p4, block_p5 As Integer
Public block_p6, block_p7, block_p8, block_p9, block_p10 As Integer
and
Dim ant1 As Integer
- - - - -
thz.
modified on Wednesday, February 25, 2009 6:55 AM
|
|
|
|
|
The code is not readable at all, use the code tag. Can you just post the relevant section of the problem only?
|
|
|
|
|
I can barely read this, and frankly, poorly written.
The reason why you don't see the updates is because your code is blocking the WM_PAINT messages being sent to your controls so they can repaint themselves according to the new Text and BackColor properties. When you make a change to a control, you do not see the change until the UI thread (which is running more of your code) gets a chance to process any pending messages in your applications message pump. This includes getting around to processing WM_PAINT messages triggered by the changes you made to your controls, pt1 and TextBoxY.
To get around this and keep your UI thread available, you would normally move all of your processing code to a background thread and raise events or use some other communication scheme to tell the UI thread how to updates the controls. But, seeing as how your pretty much a beginner at writing code, this concept may be way beyond your coding abilities for now.
|
|
|
|
|
hi.
and thz for the reply.
i found a simple solution.
just added the command :
update()
|
|
|
|
|
Yeah, that works. But, when your forms get more complicated, you'll find that using Update can cause you some unwanted side-effects. Just keep a heads up...
|
|
|
|
|
hi..
what would be an alternative to update()
if u can. plz. post some code.
PS : and do u mean i look like a beginner because i'm not using oop ???
|
|
|
|
|
hugblue wrote: if u can. plz. post some code.
There are thousands of examples all over the web. All it takes is a little Google, like search for "vb.net BackgroundWorker" or "vb.net thread tutorial".
hugblue wrote: PS : and do u mean i look like a beginner because i'm not using oop ???
Yes, among a list of other things about your code...
|
|
|
|
|
thz dave..
will look into it. and start study some oop.
but the logic in it is damn hard and there are so many new things to learn. Ss.
but thz. for the answers.
|
|
|
|
|
hi all
i m in window application
i have created a project in VS2008 in VB.Net
Now i want to create a setup for my client but i dont know how to create a setup for window project
Please help
its urgent
Thanks
Jagwinder Walia
Er. Jagwinder Singh
|
|
|
|
|
You have an option in Visual studio itself - [^]
|
|
|
|
|
Below is a C function for calculating a custom CRC32 using a static table. I need to create the same function in VB, but I know very little C language. I need to be able to calculate the CRC32 for a file selected by the user.
/*
// *****************************************************************************
CRC32
// *****************************************************************************
*/
/*------------------------------------------------------
lookup toble for CRC32 generation
------------------------------------------------------*/
#include <platform.h>
#include "cache.h"
unsigned long CRCtable[256] =
{
0x00000000L, 0x04c11db7L, 0x09823b6eL, 0x0d4326d9L,
0x130476dcL, 0x17c56b6bL, 0x1a864db2L, 0x1e475005L,
0x2608edb8L, 0x22c9f00fL, 0x2f8ad6d6L, 0x2b4bcb61L,
0x350c9b64L, 0x31cd86d3L, 0x3c8ea00aL, 0x384fbdbdL,
0x4c11db70L, 0x48d0c6c7L, 0x4593e01eL, 0x4152fda9L,
0x5f15adacL, 0x5bd4b01bL, 0x569796c2L, 0x52568b75L,
0x6a1936c8L, 0x6ed82b7fL, 0x639b0da6L, 0x675a1011L,
0x791d4014L, 0x7ddc5da3L, 0x709f7b7aL, 0x745e66cdL,
0x9823b6e0L, 0x9ce2ab57L, 0x91a18d8eL, 0x95609039L,
0x8b27c03cL, 0x8fe6dd8bL, 0x82a5fb52L, 0x8664e6e5L,
0xbe2b5b58L, 0xbaea46efL, 0xb7a96036L, 0xb3687d81L,
0xad2f2d84L, 0xa9ee3033L, 0xa4ad16eaL, 0xa06c0b5dL,
0xd4326d90L, 0xd0f37027L, 0xddb056feL, 0xd9714b49L,
0xc7361b4cL, 0xc3f706fbL, 0xceb42022L, 0xca753d95L,
0xf23a8028L, 0xf6fb9d9fL, 0xfbb8bb46L, 0xff79a6f1L,
0xe13ef6f4L, 0xe5ffeb43L, 0xe8bccd9aL, 0xec7dd02dL,
0x34867077L, 0x30476dc0L, 0x3d044b19L, 0x39c556aeL,
0x278206abL, 0x23431b1cL, 0x2e003dc5L, 0x2ac12072L,
0x128e9dcfL, 0x164f8078L, 0x1b0ca6a1L, 0x1fcdbb16L,
0x018aeb13L, 0x054bf6a4L, 0x0808d07dL, 0x0cc9cdcaL,
0x7897ab07L, 0x7c56b6b0L, 0x71159069L, 0x75d48ddeL,
0x6b93dddbL, 0x6f52c06cL, 0x6211e6b5L, 0x66d0fb02L,
0x5e9f46bfL, 0x5a5e5b08L, 0x571d7dd1L, 0x53dc6066L,
0x4d9b3063L, 0x495a2dd4L, 0x44190b0dL, 0x40d816baL,
0xaca5c697L, 0xa864db20L, 0xa527fdf9L, 0xa1e6e04eL,
0xbfa1b04bL, 0xbb60adfcL, 0xb6238b25L, 0xb2e29692L,
0x8aad2b2fL, 0x8e6c3698L, 0x832f1041L, 0x87ee0df6L,
0x99a95df3L, 0x9d684044L, 0x902b669dL, 0x94ea7b2aL,
0xe0b41de7L, 0xe4750050L, 0xe9362689L, 0xedf73b3eL,
0xf3b06b3bL, 0xf771768cL, 0xfa325055L, 0xfef34de2L,
0xc6bcf05fL, 0xc27dede8L, 0xcf3ecb31L, 0xcbffd686L,
0xd5b88683L, 0xd1799b34L, 0xdc3abdedL, 0xd8fba05aL,
0x690ce0eeL, 0x6dcdfd59L, 0x608edb80L, 0x644fc637L,
0x7a089632L, 0x7ec98b85L, 0x738aad5cL, 0x774bb0ebL,
0x4f040d56L, 0x4bc510e1L, 0x46863638L, 0x42472b8fL,
0x5c007b8aL, 0x58c1663dL, 0x558240e4L, 0x51435d53L,
0x251d3b9eL, 0x21dc2629L, 0x2c9f00f0L, 0x285e1d47L,
0x36194d42L, 0x32d850f5L, 0x3f9b762cL, 0x3b5a6b9bL,
0x0315d626L, 0x07d4cb91L, 0x0a97ed48L, 0x0e56f0ffL,
0x1011a0faL, 0x14d0bd4dL, 0x19939b94L, 0x1d528623L,
0xf12f560eL, 0xf5ee4bb9L, 0xf8ad6d60L, 0xfc6c70d7L,
0xe22b20d2L, 0xe6ea3d65L, 0xeba91bbcL, 0xef68060bL,
0xd727bbb6L, 0xd3e6a601L, 0xdea580d8L, 0xda649d6fL,
0xc423cd6aL, 0xc0e2d0ddL, 0xcda1f604L, 0xc960ebb3L,
0xbd3e8d7eL, 0xb9ff90c9L, 0xb4bcb610L, 0xb07daba7L,
0xae3afba2L, 0xaafbe615L, 0xa7b8c0ccL, 0xa379dd7bL,
0x9b3660c6L, 0x9ff77d71L, 0x92b45ba8L, 0x9675461fL,
0x8832161aL, 0x8cf30badL, 0x81b02d74L, 0x857130c3L,
0x5d8a9099L, 0x594b8d2eL, 0x5408abf7L, 0x50c9b640L,
0x4e8ee645L, 0x4a4ffbf2L, 0x470cdd2bL, 0x43cdc09cL,
0x7b827d21L, 0x7f436096L, 0x7200464fL, 0x76c15bf8L,
0x68860bfdL, 0x6c47164aL, 0x61043093L, 0x65c52d24L,
0x119b4be9L, 0x155a565eL, 0x18197087L, 0x1cd86d30L,
0x029f3d35L, 0x065e2082L, 0x0b1d065bL, 0x0fdc1becL,
0x3793a651L, 0x3352bbe6L, 0x3e119d3fL, 0x3ad08088L,
0x2497d08dL, 0x2056cd3aL, 0x2d15ebe3L, 0x29d4f654L,
0xc5a92679L, 0xc1683bceL, 0xcc2b1d17L, 0xc8ea00a0L,
0xd6ad50a5L, 0xd26c4d12L, 0xdf2f6bcbL, 0xdbee767cL,
0xe3a1cbc1L, 0xe760d676L, 0xea23f0afL, 0xeee2ed18L,
0xf0a5bd1dL, 0xf464a0aaL, 0xf9278673L, 0xfde69bc4L,
0x89b8fd09L, 0x8d79e0beL, 0x803ac667L, 0x84fbdbd0L,
0x9abc8bd5L, 0x9e7d9662L, 0x933eb0bbL, 0x97ffad0cL,
0xafb010b1L, 0xab710d06L, 0xa6322bdfL, 0xa2f33668L,
0xbcb4666dL, 0xb8757bdaL, 0xb5365d03L, 0xb1f740b4L
};
/*----------------------------------------------------------------------------
----------------------------------------------------------------------------*/
unsigned long CalcCRC(unsigned long val, unsigned char *buf, unsigned long len)
{
unsigned long accum;
EnableCaches();
for(accum = val; len > 0; len--, buf++)
accum = (accum<<8) ^ (CRCtable[(unsigned char)(accum>>24)^(*buf)]);
DisableCaches();
return accum;
}
Here is my proposed VB input to the function.
' CRC32:
Dim f As FileStream = New FileStream(txtFileName, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
crc = c.GetCrc32(f)
f.Close()
Any help or direction would be greatly appreciated!
|
|
|
|
|
The array can be declared in VB as
Dim CRCtable(255) As ULong = { _
... Fill in with values. NB will need line continuation chars at end of each line
}
You can just copy and paste the existing declaration with three points to note.
First C does not have line continuation character so you'll have to add them.
Secondly, you don't need the ; after closing }.
Thirdly, the size needs to be changed from 256 to 255.
The function is trickier but this seems a reasonable attempt
Public Function CalcCRC(ByVal val, As ULong, ByVal buf as Byte[], ByVal len As ULong) As ULong
{
Dim accum As ULong
Dim i As Integer = 0
' Dont know what this does not standard C - EnableCaches()
accum = val
do while (len > 0)
accum = (accum<<8) Xor (CRCtable((accum>>24) Xor buf(i)))
len = len - 1
i = i + 1
loop
' Dont know what this does not standard C - DisableCaches()
return accum
}
Possible problems:
1 The unsigned long type in C can be 4 or 8 bytes. The spec just says its size got to be at least as big as an int. So you might have to use UInt instead of ULong. The values in the array only take 4 bytes so my guess is you should use UInt.
2. A C unsigned char is essentially the same as a VB byte. So the unsigned char *buf parameter is pointing at an array of bytes (I assume of length given by len).
3. You might get off by one errors. C arrays always start at 0 with maximum index given by 1 less than in declaration. E.g int myArray[5]; gives an array of 5 elements with index 0 to 4.
4. I have no idea what EnableCaches/DisableCaches do - they are not standard C functions. My guess is they provide some sort of protection against array out of bounds exceptions.
5. This (accum>>24) Xor buf(i)) calculates an index into the array. You might have to do this using another variable. I'm not sure if this will always be in range 0 to 255. And you might have to do some casting to make it an integer.
Regards
David R
|
|
|
|
|
Hi,
I have two forms. The second form is called by the 1st one. I set color values for some global variables in 2nd form. The controls in 1st form uses this values for their background color.
The question is: Is there a way to set the 1st form's controls background color immediately when the variable recieves a value. I decided to use form1.refresh to see if the changes would take effect after assignment. But it didn't change. Is there a short way to realize that?
Thanks.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
You have to write code on Form1 to set the BackColor of every control you want to change yourself. There is no magic that does it for you. The control have no idea that the value you used changed. They look at their own internal property values, not your "global" variable.
|
|
|
|
|
I have a tcp server that accept connections and handle clients request. It has been running without any known issues for a few weeks. Recently I have made some mods to handle different requests and now I have been getting an InvalidOperationException Error "the Undo operation encountered a context that is different from what was applied in the corresponseding Set operation. the possible cause is that a contect was Set on the thread and not reverted(undone)" When i started getting this error, I reverted back to a previous version and now I am getting the error on that version. This makes me believe I have an underlying intermittent threading problem.
One of the things I am doing is creating a new instance of a custom class (Query) in which an instance of another custom class (Trigger) is passed by reference. From within query I am accessing properties and and manipulating data. Could this be causing the problem. Like i said before, It was working like this previously, this is a new error. I am having a hard time tracking down the error bc frankly i do not really understand it.
|
|
|
|
|
Hi,I was wondering if anyone can help me to generate a thumbnail images from a list of graphic files on a CD so I can catalog to content of each CD.
file types are *.jpg, *.Gif etc...
I am using VB 2008,
Thanks
Simon
sybaco@gmail.com
simon
|
|
|
|
|
There are a ton of thumbnail generation articles all over the web, including here at CP. All you have to do is Google for "vb.net create thumbnail image[^]" to find them. I'd tell you how to do it myself, but I wouldn't be adding anything to the couple hundred thousand explainations out there right now...
|
|
|
|
|
Dave, Thanks, I just do not have the time I am a newbie so it will take me lots of time, so I have again visited Rentacoder, all is well and thank you again, Just for my own knowledge I will browse the web,
Simon
simon
|
|
|
|
|
Good Luckk with that!
|
|
|
|
|
Hi. I'm busy with a app that needs to print xml rendered by xslt. Currently I am printing with internet explorer in the following manner
<pre>
Dim internetExplorer As New SHDocVw.InternetExplorerClass() Dim webBrowser As SHDocVw.IWebBrowser2 = CType(internetExplorer, SHDocVw.IWebBrowser2) 'Make the web browser visible webBrowser.Visible = False 'Display empty page so we have something to manipulate. Dim noValue As Object = System.Reflection.Missing.Value webBrowser.Navigate("file://" + fileName, noValue, noValue, noValue, noValue) While webBrowser.Busy Threading.Thread.Sleep(500) End While 'Get access to the webbrowser's document. internetExplorer.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, noValue, noValue) 'CType(internetExplorer.Document, mshtml.IHTMLDocument2).close() Marshal.ReleaseComObject(internetExplorer) Marshal.ReleaseComObject(webBrowser)
</pre>
I need to find a different way to do this as the above code gives a com exception. Or I need a workaround for the above code. If anybody can help I would greatly appreaciate it.
Stephen
Stephen Lintott Bsc IT (RAU)
|
|
|
|
|
Don't repeat the same question again and again in the same day. You just posted this 7 hours ago and haven't waited long enough for a response. I just started playing around with your code, not 2 minutes ago and need time to look it the problem.
|
|
|
|
|
Sorry I just under presure to get an answer for this. Any luck so far because I am stuck
Stephen Lintott Bsc IT (RAU)
|
|
|
|
|
Yeah, and I'm under pressure to test 96 applications by the end of this week...
CodeProject is supported entirely by people who volunteer their time. We get around to answering questions as much as we can whenever we can, but on our own time. We don't get paid to do this.
|
|
|
|
|
Dear All,
I am looking for to convert code of C# to VB.net is any possibility or guideline then please guide me.
Thanks
Sajjad Ali
|
|
|
|
|