Custom Dialog Box by NJ Dude

roarnold

Active Member
Licensed User
Longtime User
I installed the libs, placed the objects and like where they belong. I created a class in my program but when I Dim'd the MyMsgBox As CustomMsgBox it showed up red in the globals. Any ideas?

Thanks,
R


Code:

'Class module
Sub Class_Globals
Dim myMsgBox As CustomMsgBox - this shows red
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
'Without Icon
myMsgBox.Initialize(Activity, Me, "Default", "H", 1, 95%x, 200dip, Null)

'Then add text to the Title and Body of the custom msgbox
myMsgBox.Title.Text = "Custom MsgBox v1.0"

myMsgBox.ShowMessage("Simple box with 1 button, horizontal")

...

'This routine will get the button tapped, in this case "Default"
'is the name of the message box, you can name yours with whatever name you like
Sub Default_Click

Msgbox(myMsgBox.ButtonSelected, "Button Pressed")

End Sub


/Code
 

roarnold

Active Member
Licensed User
Longtime User
NJ Dude,

Agreed. I only made sure of these:

- B4A 2.xx
- RichString Lib
- StringUtils Lib
- Add the Class module "CustomMsgBox.bas" to your project


And installed in program. MyMsgBox is red after Dim. Not sure why?

Thanks,
R
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
NJD,

THis is what I have which is essentially your mainly to see how it reacts.myMsgBox is in red even after Dim'ing it.

'Class module
Sub Class_Globals
Dim myMsgBox As CustomMsgBox
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
'Without Icon
myMsgBox.Initialize(Activity, Me, "Default", "H", 1, 95%x, 200dip, Null)

'Then add text to the Title and Body of the custom msgbox
myMsgBox.Title.Text = "Custom MsgBox v1.0"

myMsgBox.ShowMessage("Simple box with 1 button, horizontal")

...

'This routine will get the button tapped, in this case "Default"
'is the name of the message box, you can name yours with whatever name you like
Sub Default_Click

Msgbox(myMsgBox.ButtonSelected, "Button Pressed")

End Sub



Thx R
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
Why you have this in the class?
B4X:
'Class module
 Sub Class_Globals
 Dim myMsgBox As CustomMsgBox
 End Sub

The Dim myMsgBox must be on your activity, you better post your code to see where is the problem.
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
Btw:

CustomMsgBox.Bas was placed in the project location that has the other .Bas files.

I uploaded a zip file for your review on how I am utilizing it.

Please let me know your thoughts.

Thanks for the help in advance,
R
 

Attachments

  • diagbox.zip
    73.9 KB · Views: 256
Upvote 0

NJDude

Expert
Licensed User
Longtime User
Ok, look at the attached file, it's your project and I added the CustomMsgBox class to it.

You didn't follow the instructions, the class WASN'T part of your project.

Also, like I mentioned on my previous post, you have to DIM the class on your ACTIVITY you don't have to create a class.
 

Attachments

  • SampleClass.zip
    76.3 KB · Views: 234
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
NJD,

I d/l the file you posted but don't see the changes. Sorry, sometimes I can be thick.I went back to review what Erel wrote and will research further.

Thanks,
R
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
NJD,

Almost. I utilize your CustomMsgBox as a "Class" module, then Dim it in my calling activity i.e. "Dim MyMsgBox As CustomMsgBox". The issue is that MyMsgBox As CustomMsgBox shows red in the calling activity.

Maybe I am a bit confused between all the info I have read.

Let me know if you want the project zipped.

Thanks,
R
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
NJD,

AddNew has the Dim in it as that is the first place I need a popup msg box. Essentially, just asking the individual if they are sure they want to save the file. Then it writes to a db.

If I place your CustomMsgBox in an Activity Module the Dim is ok. If I create it as a class it turns the DIM in the AddNew Activity Red.

:BangHead:

Thanks R
 

Attachments

  • obreportformsgbox.zip
    70.3 KB · Views: 204
Upvote 0

NJDude

Expert
Licensed User
Longtime User
What you have done on the "AddNew" activity is the correct way, that's how you use it, I'm not sure what you mean by: "If I create it as a class it turns the DIM in the AddNew Activity Red.". I don't exactly know what is confusing you.
 
Upvote 0

roarnold

Active Member
Licensed User
Longtime User
Like I mentioned I create your code as a class by adding it through the Project Add Module but the Dim in the calling Activity is red. If I just add your module like any other it doesn't turn the dim red in the calling activity. I just compile the code and received a null pointer error on "MyMsgBox.Title.Text = "OK to Save"
so I am close I would think.
Thanks, Dude

R
 
Upvote 0
Top