Click here to Skip to main content
15,903,012 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: need help calculator do not accept more than max char on textbox Pin
vblearner0918-Aug-09 7:59
vblearner0918-Aug-09 7:59 
QuestionVariable Depth For Loop to create a number sequence...how?! Pin
Aaron @ Think Software17-Aug-09 14:43
professionalAaron @ Think Software17-Aug-09 14:43 
AnswerRe: Variable Depth For Loop to create a number sequence...how?! Pin
Christian Graus17-Aug-09 14:56
protectorChristian Graus17-Aug-09 14:56 
GeneralRe: Variable Depth For Loop to create a number sequence...how?! Pin
Aaron @ Think Software17-Aug-09 14:59
professionalAaron @ Think Software17-Aug-09 14:59 
AnswerRe: Variable Depth For Loop to create a number sequence...how?! Pin
Aaron @ Think Software17-Aug-09 15:38
professionalAaron @ Think Software17-Aug-09 15:38 
GeneralRe: Variable Depth For Loop to create a number sequence...how?! Pin
Luc Pattyn17-Aug-09 15:46
sitebuilderLuc Pattyn17-Aug-09 15:46 
AnswerRe: Variable Depth For Loop to create a number sequence...how?! Pin
Moreno Airoldi18-Aug-09 3:50
Moreno Airoldi18-Aug-09 3:50 
QuestionAccessViolationException when resizing an image Pin
Sonhospa17-Aug-09 12:02
Sonhospa17-Aug-09 12:02 
Good evening everybody,

in a viewer application I display images read from a non-GDI-compatible format through an RGB array:
Dim arrayImage() As Byte = MakeRGBArray(Me.DPXFile, ImageOffset, Width)
Dim gch As GCHandle = GCHandle.Alloc(arrayImage, GCHandleType.Pinned)
Dim pBuf As IntPtr = gch.AddrOfPinnedObject

PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
PictureBox1.Image = New Bitmap(Width, Height, 3 * Width, Imaging.PixelFormat.Format24bppRgb, pBuf)
gch.Free()
This basically works, but from time to time I run into trouble (i.e. the program crashes) when resizing or refreshing the form or the picture box. The AccessViolationException reports an attempt to read from protected memory, so I figure D'Oh! | :doh: the GCHandle might not be freed before unloading the picture Confused | :confused:

I'm not experienced regarding the memory details, but it seems to work to leave the last line away and free the handle just before the next picture is loaded with If gch.IsAllocated Then gch.Free(). Could anybody please tell me if I'm on the right track with that or running into the next trouble? More questions arise from that, like: Would the handle be freed automatically when the form is closed?

Thanks for advice
Mick
AnswerRe: AccessViolationException when resizing an image Pin
Christian Graus17-Aug-09 13:40
protectorChristian Graus17-Aug-09 13:40 
AnswerRe: AccessViolationException when resizing an image Pin
Luc Pattyn17-Aug-09 14:42
sitebuilderLuc Pattyn17-Aug-09 14:42 
GeneralRe: AccessViolationException when resizing an image Pin
Sonhospa17-Aug-09 19:15
Sonhospa17-Aug-09 19:15 
QuestionUsing %windir% in File.copy Pin
Ghost_80717-Aug-09 11:03
Ghost_80717-Aug-09 11:03 
AnswerRe: Using %windir% in File.copy ... oppps VB Pin
Adam R Harris17-Aug-09 11:29
Adam R Harris17-Aug-09 11:29 
AnswerRe: Using %windir% in File.copy Pin
Sonhospa17-Aug-09 11:36
Sonhospa17-Aug-09 11:36 
AnswerRe: Using %windir% in File.copy Pin
Ghost_80717-Aug-09 12:03
Ghost_80717-Aug-09 12:03 
GeneralRe: Using %windir% in File.copy Pin
Dave Kreskowiak17-Aug-09 14:34
mveDave Kreskowiak17-Aug-09 14:34 
GeneralRe: Using %windir% in File.copy Pin
Ghost_80718-Aug-09 3:06
Ghost_80718-Aug-09 3:06 
GeneralRe: Using %windir% in File.copy Pin
Dave Kreskowiak18-Aug-09 4:20
mveDave Kreskowiak18-Aug-09 4:20 
GeneralRe: Using %windir% in File.copy Pin
Ghost_80718-Aug-09 6:44
Ghost_80718-Aug-09 6:44 
GeneralRe: Using %windir% in File.copy Pin
Ghost_80718-Aug-09 9:53
Ghost_80718-Aug-09 9:53 
QuestionAutomatically starting VB 6 application at Windows Start Up Pin
RyJaBy17-Aug-09 7:02
RyJaBy17-Aug-09 7:02 
AnswerRe: Automatically starting VB 6 application at Windows Start Up Pin
Dave Kreskowiak17-Aug-09 8:07
mveDave Kreskowiak17-Aug-09 8:07 
QuestionHow to print page with Visual Basic 2008? Pin
Mohamed_Khalil17-Aug-09 6:31
Mohamed_Khalil17-Aug-09 6:31 
AnswerRe: How to print page with Visual Basic 2008? Pin
Henry Minute17-Aug-09 7:06
Henry Minute17-Aug-09 7:06 
QuestionAdding a Positive Double to Negative Double Pin
KeithF17-Aug-09 3:43
KeithF17-Aug-09 3:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.