|
Ok thanks alot. I found another problem with my code where I completely skipped over my statements that enabled the timer. It works now haha. Thanks for the help and time, i really appreciate it.
|
|
|
|
|
how to use char.isdigit and char.iscontrol
to check whether entered value is number or not .
if textbox1 is blank then cursor should not go ahead means space bar in textbox1 will not allow the cursor to go ahead.
on which event char.isdigit and char.iscontrol works in vb.net.
i want to enter only numeric values in textbox1.
|
|
|
|
|
You can use it this way in KeyDown event:
If Not (Char.IsDigit(ChrW(e.KeyData))) And Not (Char.IsControl(ChrW(e.KeyData))) Then
e.SuppressKeyPress = True
'
'Show your message
'
End If
I don't use VB hence there might be a better way to write this.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
on KeyPress just use this code simple it will not let you enter any chars except numeric values
If (Char.IsLetter(e.KeyChar) Or Char.IsControl(e.KeyChar)) Then e.Handled = True
Best Of Regards,
SOFTDEV
Sad like books with torn pages, sad like unfinished stories ...
|
|
|
|
|
Hi Experts,
I am writing a code on key down event of gridview. when all the coloumn of gridview is filled and when i press F1 key code doesn't work but when i go to next row or previous cell and press F1 then the code work properly. But I want same operation without changing the cell or coloumn.
Please help me .
Thanking you,
Ajit
|
|
|
|
|
While Data Save, before updating to your DataAdapter, you have to send a command like a below..Select it's
FirstDisplayedcell and then update, your problem will solve.
MyDataGrid2.CurrentCell = MyDataGrid2.FirstDisplayedCell
MyDataGrid2.EndEdit()
DAD31.Update(DS31.Tables(0))
|
|
|
|
|
pls reffer ProcessDialogKey function
|
|
|
|
|
i m entering number in textbox1 only.
for that i m using
event
protected sub textbox1_keydown()
if e.keycode < 48 or e.keycode > 57 then
msgbox("only number allowed")
textbox1.clear()
end if
end sub
my problem is that still 1 character is entered using this code.
and i dont want any character to be entered in textbox but only the number is allowed to entered .and the cursor should not go ahead when blank textbox.plz solve my problem.
|
|
|
|
|
This code is crap, where did you find it ? Use Char.IsDigit and Char.IsControl ( the second, so that you accept keys like the arrows and delete ). Why would you clear the texbox, instead of just rejecting the key ? The keypress event has a Handled property you can set to true to reject the keypress.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
|
This is a common problem. Break it down. First you need to know how many significant figures there are, then you read each and insert the right text. In fact, this is homework so often that there's plenty of solutions online.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
sorry my English is poor so maybe i don't understand what u said.
but i need suitable code or solution for it.
thanks for your reply and help to me.
|
|
|
|
|
Hello everybody,
I guess I could really use some strategic advice for this programming challenge: Despite having to handle several image frames with up to 12 MB each, I'm heading for optimum performance! Here are some basic questions that seem to be important in order to find the track, and I'd be happy to have some experienced comments on my ideas as well as possible alternatives... and of course additional "guru" hints and ideas
One of the operations to programmatically do on a series of picture frames is a comparison of each pixel's value through the timeline of n loaded frames (where n should be "as many as possible"). Btw the picture files carry the pixel information in a UInt32 value with 10 bits each for RGB!
- I plan to read each pictures raw data into a 2-dimensional array of UInt32 first, and place the different pictures data into the third dimension of the same array. Is that construct a) useful for later picture transformation purposes, b) fast and c) safe enougth from the garbage collector to prevent me from memory allocation issues?
- Regarding upcoming memory issues (array size): How would I realize something like FIFO - i.e. that in a set of n frames the first frame is disposed when the n+1st frame is loaded?
- I read a bit about "cached bitmaps" which are said to boost performance, but all the information I could find was in C++ ... Is it possible to use cached bitmaps in VB, too? If yes then how would that be possible??? --> Although I guess I can't use them here (the source pic would most likely have to be converted to 8-bit and lose color detail information this way), some more information about this magic kind of bitmaps would be interesting anyway!
- Since a conversion to GDI+ standard bitmap might be too time consuming, I think I should only convert and display the data as bitmap (as far as I know I'll have to bit-shift, allocate memory etc. then) when it's really needed to see a result. Or is it the same, performance-wise?
- Would it make sense to think about threading in the context? Like letting one thread read the files and construct the array while another thread converts and displays the first picture?
It's a lot of questions, and I really hope for some hints from you to gain some security about "the right way" (programming-wise )
Thanks in advance
Mick
|
|
|
|
|
Hi,
here are some answers and some thoughts:
1. when performance matters, I stay far away from multi-dimensional arrays, I use one-dimensional arrays instead. A simple reason is the compiler needs to translate arr[i,j] into an address calculation that involves at least one multiplication and one addition, something like i*jmax+j (plus multiplying by the number of bytes per element and adding the base address). The next time through the loop, both i and j could have changed; when I know I am stepping one way, I can simply add a constant to the one index I have in a one-dimensional array. This wins every time.
2. If GDI+ doesn't help you in your most time-consuming part of the job, then stay away from it. A 32-bit pixel value that you understand (and GDI+ doesn't) is fine by me.
3. Storing several images into the next dimension of an array does not make sense to me, as it doesn't bring any advantage. You can keep several frames each in a separate "bitmap" arrays (not the GDI+ one), and hold these in any collection you choose, say a List. Or an array, but then it is an array of arrays, quite different from a 2-D array.
4. Assuming all images in one run have the same size, I would NOT allocate new large objects as soon as everything has been set up, instead I would reuse them; this avoids:
- out-of-memory situations and GC cycles
- possibly cache trashing
There are two possible disadvantages:
- you must make sure you don't confuse old and new images (letting them fade away and be collected is easier and safer);
- you don't get the array initialized to all zeroes (often not relevant in image processing).
5. So I would come up with a Frames class, that knows how to allocate frames initially, and can recycle frames that got freed.
6. I would absolutely apply some kind of slicing, so all the data of interest can fit in L1 and L2 caches as much as possible. So rather than performing operations op1 and op2 consecutively on an entire image, I'd rather do op1 and op2 on the top 10% of the image, then the next 10%, etc. This can dramatically improve speed for some operations.
7. I always avoid copying data. The cost of image operations can be expressed as the number of multiplications, shifts, adds and compares; these are necessary to achieve the functions you are after; copying data does not achieve a thing, so try and avoid it.
8. For performance, be aware of the difference between debug and release builds. Debug builds are hardly optimized at all.
9. In C++ you would use pointers; in C# I would consider using pointers. In VB.NET you are a bit out of luck. VB isn't very appropriate for heavy stuff, let alone image processing.
10. If you're really an advanced programmer, you would consider using SIMD (that is the vector extensions to the x86 instruction set, known as MMX/SSE/... ) for such tasks; that would normally take a lot of tedious native code, however could be controlled by a VB app. I once did a Java image processing app that generated highly optimized SSE2 code at run-time and executed it.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thank you for the good ideas and inspirations which are valuable ! Unfortunately I'm not an advanced programmer (really ) nor could I just switch to C# or C++, but still the task is there... so I'll have to give it a shot.
The Frames class makes a lot of sense - I already had started one, which also converts the raw data to GDI when necessary. There are still some funny results: e.g. it takes 557 ms - which I first considered slow- to read and prepare a 12MB file for display (including bit-shifting, creating the bitmap etc), while it takes 6318 ms (!) to read the same file into a pixel array and convert that for display using the exact same routines...
Do you by any chance have helpful how-to information or a link about the slicing you mentioned?
|
|
|
|
|
Michael Schäuble wrote: The Frames class makes a lot of sense - I already had started one, which also converts the raw data to GDI when necessary.
No. A Frames class handles with MANY frames.
A Frame class (without s) would handle the inner stuff of a single frame.
So a Frames class would be some collection of Frame instances, but not care about the internals of a Frame.
This is similar to a Form holding ListBoxes, however the Form doesn't do anything to the content of its ListBoxes.
Michael Schäuble wrote: some funny results
I can't comment, too vague. Performance can be very tricky, for many many reasons. A big one is: has the data recently been loaded in memory, so it still is in cache. Another is: does the code happen to be optimized (some .NET classes are, I would hope; your code may not, yet). etc.
Michael Schäuble wrote: how-to information ...about the slicing
No. It is very simple: try to do all required operations on a small set of data (a few MB at most) while it is in cache, before moving to the next chunk of data, since for most image processing, when done properly, fetching the data takes more time than processing it.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi all,
I am trying to create a Multi column Drop down list in VB.NET. I have tried to add an array to each data table row but was not able to get the array in the list, i only get the first value. ie. D1, D2.
Private Sub CreateDataSource()
' Populate using a DataTable
DataTable = New DataTable("Employees")
dataTable.Columns.Add("Employee ID")
dataTable.Columns.Add("Name")
dataTable.Columns.Add("Job")
Dim arr1() As Object = {"D1", "Natalia", "Developer" }
dataTable.Rows.Add(arr1)
Dim arr2() As Object = {"D2", "Jonathan", "Developer" }
dataTable.Rows.Add(arr2)
multiColumnComboBoxEx1.DataSource = dataTable
multiColumnComboBoxEx1.DisplayMember = "Employee ID"
multiColumnComboBoxEx1.ValueMember = "Name"
End Sub
How, ever the C# version of the code works fine.
private void CreateDataSource()
{
dataTable = new DataTable("Employees");
dataTable.Columns.Add("Employee ID", typeof(string));
dataTable.Columns.Add("Name", typeof(string));
dataTable.Columns.Add("Job", typeof(string));
dataTable.Rows.Add(new string[] { "D1", "Natalia", "Developer" });
dataTable.Rows.Add(new string[] { "D2", "Jonathan", "Developer" });
multiColumnComboBoxEx1.DataSource = dataTable;
multiColumnComboBoxEx1.DisplayMember = "Employee ID";
multiColumnComboBoxEx1.ValueMember = "Name";
}
Please give me some idea as to why it does not work with VB.NET.
Thanks
|
|
|
|
|
I do not know why your code does not work in VB.NET, but if I had a problem like this the first thing I would do is top make my VB code match my c# code as closely as possible.
So to start try changing:
dataTable.Columns.Add("Employee ID")
dataTable.Columns.Add("Name")
dataTable.Columns.Add("Job")
to:
dataTable.Columns.Add("Employee ID", Type.GetType("System.String"))
dataTable.Columns.Add("Name", Type.GetType("System.String"))
dataTable.Columns.Add("Job", Type.GetType("System.String"))
and:
Dim arr1() As Object = {"D1", "Natalia", "Developer" }
dataTable.Rows.Add(arr1)
Dim arr2() As Object = {"D2", "Jonathan", "Developer" }
dataTable.Rows.Add(arr2)
to:
dataTable.Rows.Add(New String() {"D1", "Natalia", "Developer"})
dataTable.Rows.Add(New String() {"D2", "Jonathan", "Developer"})
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Even with the proper coversion I am not able to get the multiple column. It looks like i m not able to create load the array on to the dropdown list.
thnx
|
|
|
|
|
i am using the drawimageunscaled from drawing a bitmap
before showing the image
i am setting the height and width of form = that of bitmap
height = b.height
width = b.width
but if the image is large, say, 3 megapixels then
the size of form is limited to resolution of monitor
what should i do?
TheMrProgrammer
http://www.icbse.com/2009/funny-exam-answers-school-students
http://download.cnet.com/TheCalcMan/3000-2094_4-10958266.html
|
|
|
|
|
Hi,
if your system has only one screen, all forms are size-limited to the size of the screen.
you can view (part of) a larger image, and optionally provide panning; one way would be by using a scrollable control. I could do that with a Panel; you might look at ScrollableControl too.
AFAIK a PictureBox is too stupid a control to provide this functionality.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
hey thanks!
but i have one more doubt.
suppose i have a bitmap : rectangle(0,0,10000,10000)
and i want to have a another bitmap having (300,300,300,300) of the above
bitmap, how can i do that.
TheMrProgrammer
http://www.icbse.com/2009/funny-exam-answers-school-students
http://download.cnet.com/TheCalcMan/3000-2094_4-10958266.html
|
|
|
|
|
Not sure what you want exactly, however there are 4 overloads to DrawImageUnscaled, and 30 to DrawImage; there is bound to be one that can do what you want, remember you are allowed to give fractional and negative locations.
BTW: when drawing onto a Bitmap, use Graphics.FromImage().
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi
I'm having problems due to a cast (*), made by the software automatically, from string to MySqlDateTime;
Is there any way of writing the ctype operator for class string, to make the cast to MySqlDateTime ?
Can someone give some help???
(*) - the exception apears on a DataGridView, that is connected to a table in a mysql database.
I'm already using a CalendarColumn, found somewhere in the web, but as soon as I pick a value,
vb throws a exception throgh DataGridView.DataError event, saying: "invalid cast from System.String to MySql.Data.Types.MysqlDateTime"
|
|
|
|
|