# Problem with MsgBox output/TabStrip -- VB6



## asbo (Sep 21, 2001)

I have gotton around the mathematical problem and the ListBox, but now I am having trouble with displaying the answer and getting a TabStrip to work.

  

Well, I'll give it one at a time...

MsgBox Output:

The math code that i am using to do this is:

>>Private Sub Command1_Click()
>> ' max dam. gen. start
>> Char = Text1
>> Weap = Text2
>> answer = (Char + Weap) / 10
>> MsgBox "Character can inflict a maximum damgage of" [answer ges here]
>> If Check1.Value = 2 Then answer = (Char + Weap + 3) / 10
>>End Sub

Can anyone tell me what I am doing wrong? Please help me! 

TabStrips:

Alright, with the tabstrip, I have 8 different tabs. Under each tab a 2 ListBoxes must appear, but when I test it, they all display the exact same thing, and in Design Mode, I can't get to the other tabs.   

PLEASE HELP ME!


----------



## asbo (Sep 21, 2001)

ANYONE?? PLEASE HELP ME!!


----------



## roverm (Oct 10, 2001)

MsgBox "Character can inflict a maximum damgage of " & cstr(answer) & "."

Tabstrips:
Don't use it !
Use the Microsoft Tabbed Dialog Control instead!
With the tabstrip you have to add panes and in code you have to make the frame visible of the corresponding tab.
With the tabbed dialog control, the ocx handles it for you!


----------



## asbo (Sep 21, 2001)

Thank you. Will try. But only one problem with the Microsoft Tabbed Dialog Control...

IT DOES THE SAME THING!! *sob* This is SO frustrating

...

The MsgBox code does work, but the result is something like:

*EX:*
__________x = 2__________y = 3

x + y = 23

____________________________

Its REALLY weird... Can you help me with that one?


----------



## roverm (Oct 10, 2001)

If I understand correct the problem is not in the way it's displayed but the adding....

Here's a new example:

Private Sub Command1_Click() 
Dim val1 As Double
Dim val2 As Double
Dim answer As Double

val1 = CDbl(Text1.Text)
val2 = CDbl(Text2.Text)

answer = (val1 + val2) / 10 
MsgBox "Character can inflict a maximum damgage of" & cstr(answer) 
If Check1.Value = 2 Then answer = (val1 + val2 + 3) / 10 
End Sub 

Now for the problem with the tabstrip:

Using the tabbed dialog every should work ok. I use this OCX all the time....

Of course, you have to place on each tab another listbox, but I guess you are doing that....

Can you paste your code of the form which contains the tabstrip (open it with notepad, copy/paste it here).


----------



## asbo (Sep 21, 2001)

```
Begin TabDlg.SSTab SSTab1 
      Height          =   3345
      Left            =   135
      TabIndex        =   2
      Top             =   255
      Width           =   9450
      _ExtentX        =   16669
      _ExtentY        =   5900
      _Version        =   393216
      Tabs            =   7
      Tab             =   1
      TabsPerRow      =   7
      TabHeight       =   520
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Times New Roman"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      TabCaption(0)   =   "Daggers"
      TabPicture(0)   =   "Form4.frx":0000
      Tab(0).ControlEnabled=   0   'False
      Tab(0).ControlCount=   0
      TabCaption(1)   =   "Hachets"
      TabPicture(1)   =   "Form4.frx":001C
      Tab(1).ControlEnabled=   -1  'True
      Tab(1).ControlCount=   0
      TabCaption(2)   =   "Maces"
      TabPicture(2)   =   "Form4.frx":0038
      Tab(2).ControlEnabled=   0   'False
      Tab(2).ControlCount=   0
      TabCaption(3)   =   "Short Swords"
      TabPicture(3)   =   "Form4.frx":0054
      Tab(3).ControlEnabled=   0   'False
      Tab(3).ControlCount=   0
      TabCaption(4)   =   "Long Swords"
      TabPicture(4)   =   "Form4.frx":0070
      Tab(4).ControlEnabled=   0   'False
      Tab(4).ControlCount=   0
      TabCaption(5)   =   "Battle Axes"
      TabPicture(5)   =   "Form4.frx":008C
      Tab(5).ControlEnabled=   0   'False
      Tab(5).ControlCount=   0
      TabCaption(6)   =   "2-Handed Swords"
      TabPicture(6)   =   "Form4.frx":00A8
      Tab(6).ControlEnabled=   0   'False
      Tab(6).ControlCount=   0
   End
```
I think this is all of it. If not, I have uploaded the .frm file in it's .txt format.

I'll go try the button code...

Thx


----------



## asbo (Sep 21, 2001)

The button code you gave got me a lot closer, but the answer was still .3 off... Can I be sure that the

```
If Check1.Value = 2 Then answer = ((val1 + val2) +3) / 10
```
 works? A correct example would be:

(( 35 + 32 ) + 3) / 10 = 7

because 32 + 3 = 35 and 35 + 35 = 70 and 70 / 10 = 7...

Thx again


----------



## asbo (Sep 21, 2001)

Could the If sentence be in the wrong place? I'll try it...


----------



## asbo (Sep 21, 2001)

Does anyone else have any ideas??


----------



## roverm (Oct 10, 2001)

Yep, the line should be earlier, before the calculation.

I will build an example using the tabstrip and will post it here in one or 2 days ... I hope


----------



## asbo (Sep 21, 2001)

Ok. Thx. BTW, the relocation didn't make any difference. Hmm. I'll poke around and see what happens.

Regards


----------



## asbo (Sep 21, 2001)

While Roverm is working on that, does anyone have any other ideas? ANY would be appreciated. In the post above, you can d/l the form in which I'm trying to get a Tab to work. If you can help, please d/l it and write it in, (you'll have to change the extention to *.frm before you start) and e-mail it to me, or change it back to *.txt and upload it here.

Thanks in advance!

Regards,


----------



## roverm (Oct 10, 2001)

asbo, here's the promised example. Really sorry (again) forgot all about it....memory....error....input violation....
Plus spending a lot of time in a new Q&A forum:
http://www.carobit.com/CarobitExchange/ExchangeHome.asp

But, here's the code example:

VERSION 5.00
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TabCtl32.ocx"
Begin VB.Form Form1 
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin TabDlg.SSTab SSTab1 
Height = 2190
Left = 300
TabIndex = 0
Top = 375
Width = 3615
_ExtentX = 6376
_ExtentY = 3863
_Version = 393216
Tab = 2
TabHeight = 520
TabCaption(0) = "Tab 0"
TabPicture(0) = "Form1.frx":0000
Tab(0).ControlEnabled= 0 'False
Tab(0).Control(0)= "List1"
Tab(0).ControlCount= 1
TabCaption(1) = "Tab 1"
TabPicture(1) = "Form1.frx":001C
Tab(1).ControlEnabled= 0 'False
Tab(1).Control(0)= "List2"
Tab(1).ControlCount= 1
TabCaption(2) = "Tab 2"
TabPicture(2) = "Form1.frx":0038
Tab(2).ControlEnabled= -1 'True
Tab(2).Control(0)= "List3"
Tab(2).Control(0).Enabled= 0 'False
Tab(2).ControlCount= 1
Begin VB.ListBox List3 
ForeColor = &H0000C000&
Height = 1425
Left = 150
TabIndex = 3
Top = 450
Width = 3315
End
Begin VB.ListBox List2 
ForeColor = &H000000FF&
Height = 1425
Left = -74850
TabIndex = 2
Top = 450
Width = 3315
End
Begin VB.ListBox List1 
Height = 1425
Left = -74850
TabIndex = 1
Top = 450
Width = 3315
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Form_Load()

With List1
.AddItem "this is list box 1"
.AddItem "located at tab 1"
End With
With List2
.AddItem "and this is list box 2"
.AddItem "located at tab 2"
End With
With List3
.AddItem "finally list box 3"
.AddItem "located at tab 3"
End With
End Sub

It's a very simple example of the Tabbed Dialog Control, containing 3 lists.
The 3 list contain different textblocks in different colors. You'll see.

Good luck!


----------



## asbo (Sep 21, 2001)

I tried your example last night it it worked beautifully. Now, (I hope) my second to last problem:

I need to make 2 ListBoxes for each of the 7 tab and they must be the same size. I tried copying and pasting. Nope. I tried drawing a new one in each tab. Extremely difficult and will only do if there is no other way.

Does anybody have any ideas?

And 2nd problem:

The

```
If Check1.Value = 2 Then answer = (val1 +val2 + 3) / 10
```
 sentence doesn't work!! Aargh! Does anybody have any ideas about _this_ one??

Thanks in advance

Regards,


----------



## roverm (Oct 10, 2001)

>>I need to make 2 ListBoxes for tab and they must be the same size

What do you mean ? I don't understand.
Do you want to place 2 listboxes on 1 tab ? How many tabs you want ?


----------



## asbo (Sep 21, 2001)

Sorry roverm, there are a few mistakes I didnt catch. I'm about to edit it.

Regards,


----------



## asbo (Sep 21, 2001)

How STUPID I have been! The Check1.Value has been set to If.... Value = 2 !!! JEEZ!!! 2 = GREYED! 1 = CHECKED!! LOL. I figured this out with some help from a guy named Bob Resel. Awesome!

Regards,


----------



## asbo (Sep 21, 2001)

Well, all I need to do know is to devise a way to do the Tab thing... Unless any one else has suggestions...


Thanks again Roverm!!


----------



## asbo (Sep 21, 2001)

Does anyone know how I can round the answer value? I read something along those lings somewhere...

Thanks


----------



## roverm (Oct 10, 2001)

To round it you can use the INT(myrealvariable) orso.
If you want to display it nice use the Format function:


format(myvar,"0#.00") 'the point depends on your local settings, it could be a comma instead

For example if
myvar = 1234.56 ==> '1234.56'
myvar = 1234.1 ==> '1234.10'
myvar = 1234 ==> '1234,00'

Just try it.


----------



## asbo (Sep 21, 2001)

I don't understand what you mean. Could you please give an example?


----------



## roverm (Oct 10, 2001)

I gave you an example ?

Msgbox Format("1234.1","0#.00")

Further, can't you come to :

http://www.carobit.com/CarobitExchange/ExchangeHome.asp

All the major experts are there, me too. I communicates way easier!


----------



## asbo (Sep 21, 2001)

Could there be an easier way?


----------



## roverm (Oct 10, 2001)

easier than what ?


----------



## asbo (Sep 21, 2001)

What I mean is is there another way to do this because I typed exactly that into the code and it gave a syntax error. Does it matter where I place it and if text is also in the box?

Regards,


----------

