Welcome to Emulationworld

Forum Index | FAQ | New User | Login | Search

Make a New PostPrevious ThreadView All ThreadsNext Thread*Show in Threaded Mode


SubjectVisual Basic help, anyone ? Reply to this message
Posted byTi-BOne
Posted on07/12/06 11:10 AM



Ok, i am having a problem, the thing is, my code is only going so far, and when it hit the line marked with **** it simple doesnt test it.
Is there some limit for it ?
or have i reached some kind of variable limit ?

the program itself is quite big, and that if, was one of the first things, and it was working back when i coded it, i extensively tested it.
its a search form through a database. its for a real estate control program i am coding.

code is as follows

In reply to:


If Problema12.ListIndex <> 0 And Problema22.ListIndex <> 0 And urgencia2.ListIndex = 0 And cmb_valor2.ListIndex = 0 Then
'Label51.Caption = "teste"
posicao = dBase.FindText(Problema12.List(Problema12.ListIndex), inicio, 2)
If posicao = -1 Then Exit Sub
If posicao <> -1 Then
'inicio2 = posicao
dBase.AbsolutePosition = posicao
achou = dBase.Field(3)
Label1.Caption = achou
Label2.Caption = Problema22.List(Problema22.ListIndex)
Label51.Caption = achou
Label52.Caption = Label2.Caption

***** If Label1.Caption = Label2.Caption Then
List12.AddItem posicao, 0
dBase.AbsolutePosition = posicao
mostrartipo = dBase.Field(2)
List2.AddItem mostrartipo, 0
mostrardorm = dBase.Field(8)
List3.AddItem mostrardorm, 0
mostrarend = dBase.Field(0)
List4.AddItem mostrarend, 0
mostrarvalor = dBase.Field(13)
List5.AddItem mostrarvalor, 0
mostrarcontato = dBase.Field(11)
List6.AddItem mostrarcontato, 0
temfoto = dBase.Field(15)
'temfoto2 = Left(temfoto, 1)
List13.AddItem temfoto, 0
Label52.Caption = posicao
MsgBox "não falhou"
'If temfoto2 <> "" Then
' List13.AddItem "S", 0
' GoTo temfoto1
'End If
'List13.AddItem "N", 0
'temfoto1:
***** End If
posicao = posicao + 1
inicio = posicao
achou = " "

End If
End If


The part between the **** is not being tested.
and i am using label51 and label52 to check, and the values DO match, and so, the code should be doing the stuff between the **** lines.

Any ideas ?



SubjectRe: Visual Basic help, anyone ? new Reply to this message
Posted byarucard
Posted on07/12/06 11:22 AM



> Ok, i am having a problem, the thing is, my code is only going so far, and when
> it hit the line marked with **** it simple doesnt test it.
> Is there some limit for it ?
> or have i reached some kind of variable limit ?
>
> the program itself is quite big, and that if, was one of the first things, and
> it was working back when i coded it, i extensively tested it.
> its a search form through a database. its for a real estate control program i am
> coding.
>
> code is as follows
> In reply to:
> If Problema12.ListIndex 0 And Problema22.ListIndex 0 And urgencia2.ListIndex =
> 0 And cmb_valor2.ListIndex = 0 Then
> 'Label51.Caption = "teste"
> posicao = dBase.FindText(Problema12.List(Problema12.ListIndex), inicio, 2)
> If posicao = -1 Then Exit Sub
> If posicao -1 Then
> 'inicio2 = posicao
> dBase.AbsolutePosition = posicao
> achou = dBase.Field(3)
> Label1.Caption = achou
> Label2.Caption = Problema22.List(Problema22.ListIndex)
> Label51.Caption = achou
> Label52.Caption = Label2.Caption
>
> ***** If Label1.Caption = Label2.Caption Then
> List12.AddItem posicao, 0
> dBase.AbsolutePosition = posicao
> mostrartipo = dBase.Field(2)
> List2.AddItem mostrartipo, 0
> mostrardorm = dBase.Field(8)
> List3.AddItem mostrardorm, 0
> mostrarend = dBase.Field(0)
> List4.AddItem mostrarend, 0
> mostrarvalor = dBase.Field(13)
> List5.AddItem mostrarvalor, 0
> mostrarcontato = dBase.Field(11)
> List6.AddItem mostrarcontato, 0
> temfoto = dBase.Field(15)
> 'temfoto2 = Left(temfoto, 1)
> List13.AddItem temfoto, 0
> Label52.Caption = posicao
> MsgBox "não falhou"
> 'If temfoto2 "" Then
> ' List13.AddItem "S", 0
> ' GoTo temfoto1
> 'End If
> 'List13.AddItem "N", 0
> 'temfoto1:
> ***** End If
> posicao = posicao + 1
> inicio = posicao
> achou = " "
>
> End If
> End If
> The part between the **** is not being tested.
> and i am using label51 and label52 to check, and the values DO match, and so,
> the code should be doing the stuff between the **** lines.
>
> Any ideas ?
>


I don't use VB but I would have though you need to put the code after your 'if xxxx=xxxx then' statement as a block. For instance in Delphi, which I guess is pretty similar to VB it would be :
if whatever = whatever2 then
do begin
blahblahblah;
blahblahblah;
blahblahblah;
blahblahblah;
end else
'do fuck all'

That way, all the code between begin and end will get executed in order. I don't know what the equivelant of begin and end are in VB, maybe that is the problem.

Trust me, I'm a fucking Doctor.

Arucard




SubjectRe: Visual Basic help, anyone ? new Reply to this message
Posted byTi-BOne
Posted on07/12/06 01:33 PM



In VB,it works a little bit different

if i have this code :
--- if a= b then dothis ----
thatīs a line if

if i have this code :
---- if a = b then
msgbox "a equals b"
msgbox "that means a has the same value as b"
msgbox "simple math-fucker"
end if
-------------

thatīs a block if. thereīs no 'begin' and 'end' statements needed.

i have never encountered this problem before, i will do a more detailed debugging later.

But thanks anyway.


> I don't use VB but I would have though you need to put the code after your 'if
> xxxx=xxxx then' statement as a block. For instance in Delphi, which I guess is
> pretty similar to VB it would be :
> if whatever = whatever2 then
> do begin
> blahblahblah;
> blahblahblah;
> blahblahblah;
> blahblahblah;
> end else
> 'do fuck all'
>
> That way, all the code between begin and end will get executed in order. I don't
> know what the equivelant of begin and end are in VB, maybe that is the problem.
>
> Trust me, I'm a fucking Doctor.
>
> Arucard
>





SubjectRe: Visual Basic help, anyone ? new Reply to this message
Posted byMarv
Posted on07/12/06 06:12 PM



> Ok, i am having a problem, the thing is, my code is only going so far, and when
> it hit the line marked with **** it simple doesnt test it.
> Is there some limit for it ?
> or have i reached some kind of variable limit ?
>
> the program itself is quite big, and that if, was one of the first things, and
> it was working back when i coded it, i extensively tested it.
> its a search form through a database. its for a real estate control program i am
> coding.
>
> code is as follows
> In reply to:
> If Problema12.ListIndex 0 And Problema22.ListIndex 0 And urgencia2.ListIndex =
> 0 And cmb_valor2.ListIndex = 0 Then
> 'Label51.Caption = "teste"
> posicao = dBase.FindText(Problema12.List(Problema12.ListIndex), inicio, 2)
> If posicao = -1 Then Exit Sub
> If posicao -1 Then
> 'inicio2 = posicao
> dBase.AbsolutePosition = posicao
> achou = dBase.Field(3)
> Label1.Caption = achou
> Label2.Caption = Problema22.List(Problema22.ListIndex)
> Label51.Caption = achou
> Label52.Caption = Label2.Caption
>
> ***** If Label1.Caption = Label2.Caption Then
> List12.AddItem posicao, 0
> dBase.AbsolutePosition = posicao
> mostrartipo = dBase.Field(2)
> List2.AddItem mostrartipo, 0
> mostrardorm = dBase.Field(8)
> List3.AddItem mostrardorm, 0
> mostrarend = dBase.Field(0)
> List4.AddItem mostrarend, 0
> mostrarvalor = dBase.Field(13)
> List5.AddItem mostrarvalor, 0
> mostrarcontato = dBase.Field(11)
> List6.AddItem mostrarcontato, 0
> temfoto = dBase.Field(15)
> 'temfoto2 = Left(temfoto, 1)
> List13.AddItem temfoto, 0
> Label52.Caption = posicao
> MsgBox "não falhou"
> 'If temfoto2 "" Then
> ' List13.AddItem "S", 0
> ' GoTo temfoto1
> 'End If
> 'List13.AddItem "N", 0
> 'temfoto1:
> ***** End If
> posicao = posicao + 1
> inicio = posicao
> achou = " "
>
> End If
> End If
> The part between the **** is not being tested.
> and i am using label51 and label52 to check, and the values DO match, and so,
> the code should be doing the stuff between the **** lines.
>
> Any ideas ?
>

So what happens? Does it not get to that line, or does it always say that Label1.Caption <> Label2.Caption?
If it says Label1.Caption <> Label2.Caption, try checking the lengths of both strings, and then if that doesn't give a clue, get the ascii code of each character to make sure there's not an extra carriage return/line feed.
Also, check that TypeName(Label1.Caption) = TypeName(Label2.Caption) in case somehow one of them is a Variant...

Post back if you need more info, and I'll check tomorrow...




SubjectRe: Visual Basic help, anyone ? new Reply to this message
Posted byTi-BOne
Posted on07/12/06 07:09 PM



> > Ok, i am having a problem, the thing is, my code is only going so far, and
> when
> > it hit the line marked with **** it simple doesnt test it.
> > Is there some limit for it ?
> > or have i reached some kind of variable limit ?
> >
> > the program itself is quite big, and that if, was one of the first things, and
> > it was working back when i coded it, i extensively tested it.
> > its a search form through a database. its for a real estate control program i
> am
> > coding.
> >
> > code is as follows
> > In reply to:
> > If Problema12.ListIndex 0 And Problema22.ListIndex 0 And urgencia2.ListIndex
> =
> > 0 And cmb_valor2.ListIndex = 0 Then
> > 'Label51.Caption = "teste"
> > posicao = dBase.FindText(Problema12.List(Problema12.ListIndex), inicio, 2)
> > If posicao = -1 Then Exit Sub
> > If posicao -1 Then
> > 'inicio2 = posicao
> > dBase.AbsolutePosition = posicao
> > achou = dBase.Field(3)
> > Label1.Caption = achou
> > Label2.Caption = Problema22.List(Problema22.ListIndex)
> > Label51.Caption = achou
> > Label52.Caption = Label2.Caption
> >
> > ***** If Label1.Caption = Label2.Caption Then
> > List12.AddItem posicao, 0
> > dBase.AbsolutePosition = posicao
> > mostrartipo = dBase.Field(2)
> > List2.AddItem mostrartipo, 0
> > mostrardorm = dBase.Field(8)
> > List3.AddItem mostrardorm, 0
> > mostrarend = dBase.Field(0)
> > List4.AddItem mostrarend, 0
> > mostrarvalor = dBase.Field(13)
> > List5.AddItem mostrarvalor, 0
> > mostrarcontato = dBase.Field(11)
> > List6.AddItem mostrarcontato, 0
> > temfoto = dBase.Field(15)
> > 'temfoto2 = Left(temfoto, 1)
> > List13.AddItem temfoto, 0
> > Label52.Caption = posicao
> > MsgBox "não falhou"
> > 'If temfoto2 "" Then
> > ' List13.AddItem "S", 0
> > ' GoTo temfoto1
> > 'End If
> > 'List13.AddItem "N", 0
> > 'temfoto1:
> > ***** End If
> > posicao = posicao + 1
> > inicio = posicao
> > achou = " "
> >
> > End If
> > End If
> > The part between the **** is not being tested.
> > and i am using label51 and label52 to check, and the values DO match, and so,
> > the code should be doing the stuff between the **** lines.
> >
> > Any ideas ?
> >
>
> So what happens? Does it not get to that line, or does it always say that
> Label1.Caption Label2.Caption?
> If it says Label1.Caption Label2.Caption, try checking the lengths of both
> strings, and then if that doesn't give a clue, get the ascii code of each
> character to make sure there's not an extra carriage return/line feed.
> Also, check that TypeName(Label1.Caption) = TypeName(Label2.Caption) in case
> somehow one of them is a Variant...
>
> Post back if you need more info, and I'll check tomorrow...

i have checked the lenght and the ascii codes, and they seem exactly the same to me.
it is always saying that label1.caption <> label2.caption.
i will give the code a few more reads.
Maybe i can see something that i'm missing.
i will also check typename for both labels.

i will post back when/if i find anything out.




SubjectYou defile my forum with Visual Basic!? new Reply to this message
Posted bySnowball 2
Posted on07/12/06 09:11 PM



The problem is that you're using an old and shitty language. Just remember that you brought this thrashing upon yourself...

Good god man, you mix your DB code with your form code? Separate that shiznit! Have you heard of separating your application into logical layers? Business objects? And give your goddam form objects meaningful names! If I had even an incling of what relationship Problema12, Problema22, List(2,5,13), etc had then maybe it would make this easier to read. And this condition,

If posicao = -1 Then Exit Sub
If posicao <> -1 Then

If the first "If" statement isn't true then the second "If" statement has to be true! You don't need the second condition at all. And despite my cuntings I've taken the time to cut up the code and try to figure out what's going on. The question you have is "why doesn't this if statement ever return true?" We have no way of ever knowing. Label1.Caption comes from achou which is dBase.Field(3), whatever that is. Label2.Caption comes from a list which we have no idea what's in it.

Let me ask a simple question. Have you looked at this in the debugger and if you have what are the values of Label1.Caption and Label2.Caption when it hits this condition?



pixel-eight.com



SubjectThere's also a "Goto" in there ;o) -nt- new Reply to this message
Posted byMarv
Posted on07/13/06 01:45 AM



> The problem is that you're using an old and shitty language. Just remember that
> you brought this thrashing upon yourself...
>
> Good god man, you mix your DB code with your form code? Separate that shiznit!
> Have you heard of separating your application into logical layers? Business
> objects? And give your goddam form objects meaningful names! If I had even an
> incling of what relationship Problema12, Problema22, List(2,5,13), etc had then
> maybe it would make this easier to read. And this condition,
>
> If posicao = -1 Then Exit Sub
> If posicao -1 Then
>
> If the first "If" statement isn't true then the second "If" statement has to be
> true! You don't need the second condition at all. And despite my cuntings I've
> taken the time to cut up the code and try to figure out what's going on. The
> question you have is "why doesn't this if statement ever return true?" We have
> no way of ever knowing. Label1.Caption comes from achou which is
> dBase.Field(3), whatever that is. Label2.Caption comes from a list which we
> have no idea what's in it.
>
> Let me ask a simple question. Have you looked at this in the debugger and if
> you have what are the values of Label1.Caption and Label2.Caption when it hits
> this condition?
>
>
>
> pixel-eight.com
>





SubjectRe: Visual Basic help, anyone ? new Reply to this message
Posted byMarv
Posted on07/13/06 04:57 AM



> > > Ok, i am having a problem, the thing is, my code is only going so far, and
> > when
> > > it hit the line marked with **** it simple doesnt test it.
> > > Is there some limit for it ?
> > > or have i reached some kind of variable limit ?
> > >
> > > the program itself is quite big, and that if, was one of the first things,
> and
> > > it was working back when i coded it, i extensively tested it.
> > > its a search form through a database. its for a real estate control program
> i
> > am
> > > coding.
> > >
> > > code is as follows
> > > In reply to:
> > > If Problema12.ListIndex 0 And Problema22.ListIndex 0 And
> urgencia2.ListIndex
> > =
> > > 0 And cmb_valor2.ListIndex = 0 Then
> > > 'Label51.Caption = "teste"
> > > posicao = dBase.FindText(Problema12.List(Problema12.ListIndex), inicio, 2)
> > > If posicao = -1 Then Exit Sub
> > > If posicao -1 Then
> > > 'inicio2 = posicao
> > > dBase.AbsolutePosition = posicao
> > > achou = dBase.Field(3)
> > > Label1.Caption = achou
> > > Label2.Caption = Problema22.List(Problema22.ListIndex)
> > > Label51.Caption = achou
> > > Label52.Caption = Label2.Caption
> > >
> > > ***** If Label1.Caption = Label2.Caption Then
> > > List12.AddItem posicao, 0
> > > dBase.AbsolutePosition = posicao
> > > mostrartipo = dBase.Field(2)
> > > List2.AddItem mostrartipo, 0
> > > mostrardorm = dBase.Field(8)
> > > List3.AddItem mostrardorm, 0
> > > mostrarend = dBase.Field(0)
> > > List4.AddItem mostrarend, 0
> > > mostrarvalor = dBase.Field(13)
> > > List5.AddItem mostrarvalor, 0
> > > mostrarcontato = dBase.Field(11)
> > > List6.AddItem mostrarcontato, 0
> > > temfoto = dBase.Field(15)
> > > 'temfoto2 = Left(temfoto, 1)
> > > List13.AddItem temfoto, 0
> > > Label52.Caption = posicao
> > > MsgBox "não falhou"
> > > 'If temfoto2 "" Then
> > > ' List13.AddItem "S", 0
> > > ' GoTo temfoto1
> > > 'End If
> > > 'List13.AddItem "N", 0
> > > 'temfoto1:
> > > ***** End If
> > > posicao = posicao + 1
> > > inicio = posicao
> > > achou = " "
> > >
> > > End If
> > > End If
> > > The part between the **** is not being tested.
> > > and i am using label51 and label52 to check, and the values DO match, and
> so,
> > > the code should be doing the stuff between the **** lines.
> > >
> > > Any ideas ?
> > >
> >
> > So what happens? Does it not get to that line, or does it always say that
> > Label1.Caption Label2.Caption?
> > If it says Label1.Caption Label2.Caption, try checking the lengths of both
> > strings, and then if that doesn't give a clue, get the ascii code of each
> > character to make sure there's not an extra carriage return/line feed.
> > Also, check that TypeName(Label1.Caption) = TypeName(Label2.Caption) in case
> > somehow one of them is a Variant...
> >
> > Post back if you need more info, and I'll check tomorrow...
>
> i have checked the lenght and the ascii codes, and they seem exactly the same to
> me.
> it is always saying that label1.caption label2.caption.
> i will give the code a few more reads.
> Maybe i can see something that i'm missing.
> i will also check typename for both labels.
>
> i will post back when/if i find anything out.

OK. Another possibility is that although you've set the values of the label captions, the form hasn't updated them by the time it gets to that If (but when you try debugging, it's caught up, so it looks like they match) - you could try messing about using temporary string variables...



Dim label1Caption as String
Dim label2Caption as String
label1Caption = Label1.Caption
label2Caption = Label2.Caption
If label1Caption = label2Caption Then...

Else
Msgbox "Label1: " & label1Caption & "Label2: " & label2Caption
Endif








Subjecti was wondering how long it was gonna take. new Reply to this message
Posted byTi-BOne
Posted on07/13/06 08:23 AM



before someone trash on VB.

Well, yes, the code is a mess. But i was doing it for a friend in a rush, and i was getting paid for it, to deliver it on time.
Which, btw, i did, ka-fucking-ching! $$!!

But yeah Snow, i agree with you. And i will probably re-write this, now that i have no deadline.

My question was : "why does this if statement ever return true, when i am pretty sure its true", hell i even did this :

label1.caption = "1"
label2.caption = "2"
if label1.caption = label2.caption then
msgbox "it works!"
end if

and it didnīt return me true.

But i fugured why.
I took one If out of the chain, and it work.

The second if statement condition (the one that wasnīt necessary) was the key to get it to work, i simple ended it before checking label1 and label2 and it works. I tried to delete it, but then label1 and label2 returned to their never checking condition.
So i guess it was somewhat necessary.



Now,
VB is understimated. You can do a lot with VB. Its not the best language, true, but at least, i donīt have to type 400 fucking lines to get a fucking simple window drawn in my screen. (Visual C++ ? beh) I havenīt tried .Net stuff properly to say anything, because i donīt own it, and i didnīt feel like downloading all that stuff to do simple codes.

Delphi, on the other hand, seems to be the shit. However, i donīt have time to learn it. Or i am too stupid for it, which is a possibility. Which might be the problem with me learning C and its variants too.

Anyway, VB is not the root of all evil, like some people make it. Its a simple tool, for coding simple programs to do stuff. The kids that try to code a fucking operating system in VB are the stupid ones. Or the ones who thinks they can write a full 3D clone of Quake or whatever is the FPS of the moment using only VB.
But i am aware of its limitations. And for a simple dbase application, VB works, and very well, may i add.

But yeah.. what you said. hehe.







> The problem is that you're using an old and shitty language. Just remember that
> you brought this thrashing upon yourself...
>
> Good god man, you mix your DB code with your form code? Separate that shiznit!
> Have you heard of separating your application into logical layers? Business
> objects? And give your goddam form objects meaningful names! If I had even an
> incling of what relationship Problema12, Problema22, List(2,5,13), etc had then
> maybe it would make this easier to read. And this condition,
>
> If posicao = -1 Then Exit Sub
> If posicao -1 Then
>
> If the first "If" statement isn't true then the second "If" statement has to be
> true! You don't need the second condition at all. And despite my cuntings I've
> taken the time to cut up the code and try to figure out what's going on. The
> question you have is "why doesn't this if statement ever return true?" We have
> no way of ever knowing. Label1.Caption comes from achou which is
> dBase.Field(3), whatever that is. Label2.Caption comes from a list which we
> have no idea what's in it.
>
> Let me ask a simple question. Have you looked at this in the debugger and if
> you have what are the values of Label1.Caption and Label2.Caption when it hits
> this condition?
>
>
>
> pixel-eight.com
>





SubjectI'm biased new Reply to this message
Posted bySnowball 2
Posted on07/13/06 08:56 AM



I've been working in Java and .NET so the need for VB is not there at all. You can design forms and windows applications in .net regardless of what language you use be it VB, C# or *shudder* J#. VB6 was an excellent tool for its time but that time has passed. Now when I see it it makes me want to punch myself in the groin. And yeah C++, MFC and all that shiznit sucks donkey balls. HRESULT my cock.

pixel-eight.com



SubjectYar new Reply to this message
Posted byMarv
Posted on07/13/06 09:05 AM



> I've been working in Java and .NET so the need for VB is not there at all. You
> can design forms and windows applications in .net regardless of what language
> you use be it VB, C# or *shudder* J#. VB6 was an excellent tool for its time
> but that time has passed. Now when I see it it makes me want to punch myself in
> the groin. And yeah C++, MFC and all that shiznit sucks donkey balls. HRESULT
> my cock.
>
> pixel-eight.com

I'd recommend moving from VB to .NET, since it's not 100% alien, but you can appreciate the bits that are better. It's a bit of a shift to learn how proper object-oriented languages work, but it's worth it.

VB6 still has its uses though, and isn't all that bad, as long as it's written well.




Previous ThreadView All ThreadsNext Thread*Show in Threaded Mode