X-Received: by 10.182.91.37 with SMTP id cb5mr8213270obb.31.1454609787888; Thu, 04 Feb 2016 10:16:27 -0800 (PST) X-Received: by 10.50.43.165 with SMTP id x5mr217815igl.9.1454609787864; Thu, 04 Feb 2016 10:16:27 -0800 (PST) Path: csiph.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!o2no2182055iga.0!news-out.google.com!l1ni2889igd.0!nntp.google.com!hb3no617816igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: it.comp.lang.visual-basic Date: Thu, 4 Feb 2016 10:16:27 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=151.16.212.238; posting-account=eitZdgoAAAC6C9CXmyhLNaQM3MgI3eZM NNTP-Posting-Host: 151.16.212.238 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <1cdffe34-990b-4499-be9d-91fe33d73ef0@googlegroups.com> Subject: Re: [VB6] errore di runtime 5 solo su win XP From: Luca D Injection-Date: Thu, 04 Feb 2016 18:16:27 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 4318 X-Received-Body-CRC: 2452064058 Xref: csiph.com it.comp.lang.visual-basic:18683 On Thursday, February 4, 2016 at 5:50:05 PM UTC+1, carmelo wrote: > Il 04/02/2016 15:23, GbC ha scritto: > > Il 04/02/2016 14:57, carmelo ha scritto: > >> Private Type OPENFILENAME > >> lStructSize As Long > >> hwndOwner As Long > >> hInstance As Long > >> lpstrFilter As String > >> lpstrCustomFilter As String > >> nMaxCustFilter As Long > >> nFilterIndex As Long > >> lpstrFile As String > >> nMaxFile As Long > >> lpstrFileTitle As String > >> nMaxFileTitle As Long > >> lpstrInitialDir As String > >> lpstrTitle As String > >> flags As Long > >> nFileOffset As Integer > >> nFileExtension As Integer > >> lpstrDefExt As String > >> lCustData As Long > >> lpfnHook As Long > >> lpTemplateName As String > >> End Type > >> Private OFName As OPENFILENAME > >> > >> Dim FilePath As String > >> FilePath =3D Left$(OFName.lpstrFile, OFName.nFileOffset - 1) > >> > >> Mi sapreste dire perch=E8 la riga sopra, su Win XP mi da errore di run= time > >> 5: chiamata di routine o argomento non valido. > >> > >> Mentre su Vista, Seven e win 8 funziona regolarmente. > >> > >> Carmelo > > > > > > A) Metti un breakpoint prima dell'istruzione incriminata e controlli il > > contenuto delle due stringhe. > > > > debug.print "lpstrFile|" & OFName.lpstrFile & "|" > > debug.print "nFileOffset|" & OFName.nFileOffset & "|" > > stop > > ' riga esistente > > FilePath =3D Left$(OFName.lpstrFile, OFName.nFileOffset - 1) > > > > B) In alternativa aggiungi una messagebox che mostri il contenuto delle > > due stringhe, magari controllando con un parametro nella command-line s= e > > vuoi visualizzare i messaggi o no. Pu=F2 anche essere utile in altri ca= si. > > > > Setti una variabile globale booleana in un modulo .bas > > > > global myDebugMODE as boolean > > > > nel form di avvio (o quel che =E8) controlli se =E8 stato attivato il d= ebug, > > che si attiver=E0 indicando come parametro nella commandline la parola = -debug > > > > if instr(1,command,"-debug",1) > 0 then myDebugMODE =3D true > > > > (lo so che si pu=F2 fare meglio ma per ora va bene lo stesso) > > > > prima di eseguire la linea incriminata metti un > > > > if myDebugMODE =3D True then > > MsgBox "lpstrFile|" & OFName.lpstrFile & "|" & vbnewline & _ > > "nFileOffset|" & OFName.nFileOffset & "|" , _ > > vbinformation, _ > > "myDebugMODE: FilePath" > > > > end if > > > > ' riga esistente > > FilePath =3D Left$(OFName.lpstrFile, OFName.nFileOffset - 1) > > > > > > Cos=EC cosa =E8 che genere quell'errore. > > > Ho provato cosi: > Dim FilePath As String, iPos as Integer > iPos =3D (OFName.nFileOffset - 1) =3D=3D=3D=3D > questa riga da errore > FilePath =3D Left$(OFName.lpstrFile, iPos) >=20 > L'errore lo genera OFName.nFileOffset > solo in win XP perch=E8? >=20 > Carmelo Cos=EC per curiosita', hai provato ad inizializzare esplicitamente a zero t= utti i campi integer/long di quella struttura subito dopo aver dichiarato O= FName?=20