|
-
Jan 16th, 2003, 08:34 AM
#1
Thread Starter
Hyperactive Member
Edneeis - About your "Tips at Startup" progam
Edneeis, I've just visited your excellent website and discovered your "Tips at Startup" program, which is exactly what I would like to have in my VBCodebook .NET program.
Firstly, can I have your permission to include it? Secondly, is there a way you can modify it slightly to include bold italic and underline in the main tips body?
Also, could it be possible, when clicking the Next Tip button, to move onto the next tip in the list instead of picking a random one each time? Perhaps picking a random tip at the beginning and moving on to the next one, eventually looping round? This way, ALL the tips will be guarenteed to be seen.
Thanks Edneeis
Last edited by RealNickyDude; Jan 16th, 2003 at 09:30 AM.
-
Jan 16th, 2003, 02:21 PM
#2
Thanks. Sure you can use it. Here is an updated copy that can show richtext or text and can next random or not. The random bit is set by an internal const NextIsRandom and in this example is set to be NOT random. As for the bold, underline bit if you want it to show like that you have to put RichText in the tip instead of normal text. If it can't read it then it shows it as regular text and this is only on the body the headed format can't be changed dynamically.
-
Jan 16th, 2003, 02:22 PM
#3
Opps I forgot to post the zip. I'll update the website one when I get home but this is the samething.
-
Jan 16th, 2003, 03:25 PM
#4
Thread Starter
Hyperactive Member
Wow, thanks Edneeis! Just what I needed
Just a couple of questions:
1/. How do load RichText? How do I change it from reading an xml doc to a richtext doc?
2/. How would I go about displaying a random tip first (instead of the first tip) and then move to the next tip from there?
E.g: Pick a random tip at start, say, tip 4, out of 10, then clicking Next will take you to tip 5 then 6..... 9, then 10
, then back to 1 again.
Again, thanks Edneeis.
Last edited by RealNickyDude; Jan 16th, 2003 at 03:31 PM.
-
Jan 16th, 2003, 03:55 PM
#5
Thread Starter
Hyperactive Member
I've added code that tells you what tip your on, out of the number of tips there is (in bold). For anyone who's interested.
VB Code:
If NextIsRandom Then
rndRow = Int(((ds.Tables(0).Rows.Count - 1) - 0 + 1) * Rnd() + 0)
Else
rndRow += 1
End If
[b]
'Display tip number out of how many tips in titlebar
Me.Text = "Tip of the day - Tip " & rndRow _
& " out of " & ds.Tables(0).Rows.Count
[/b]
'handle outside of count
If rndRow > ds.Tables(0).Rows.Count - 1 Then rndRow = 0
If rndRow < 0 Then rndRow = ds.Tables(0).Rows.Count - 1
-
Jan 16th, 2003, 03:59 PM
#6
Thread Starter
Hyperactive Member
I've added a link to your website Edneeis from within VBCodebook .NET: Beta Release 6, is that ok?
-
Jan 16th, 2003, 04:45 PM
#7
The answer to question #1 is you don't. You still use an xml document so it can load into the dataset but you can put richtext into the Body node of the xml. You can write richtext with word, wordpad, or any other number of rtb applications. If you use Word just make sure and save it as RichText then just cut and past it in there. Or if you are using a RichTextBox then use the RTF property instead of the Text property.
As for #2 at the form load you can i'll post an update tonight. But you basically switch the IsNextRandom to a variable instead of a Constant and then change it after the first tip is loaded.
Also sure you can link to my site.
-
Jan 16th, 2003, 05:06 PM
#8
Thread Starter
Hyperactive Member
I'm not sure i'm with you on question 1. Do I load up an rtf document into a text editor to see all the rtf codes, then copy and paste that?
-
Jan 16th, 2003, 06:27 PM
#9
Yes you can do it that way. Or if you use wordpad to write the stuff how you want then open the file in notepad and copy and paste that (which will be the rtf codes also). Either way as long as the Body has the rtf codes then its all good.
Here is an updated example also.
-
Jan 22nd, 2003, 04:56 PM
#10
Thread Starter
Hyperactive Member
Edneeis, I don't know whether you'll be interested but I've updated your program to include Previous Tip to go backward through the tips and to show the tip number out of the number of tips available (properly), here's the code (italics is the update i've added):
VB Code:
[i]Dim Previous As Boolean[/i]
Private Sub NextTip(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
'load the next tip NOT random
[i]Previous = False[/i]
FillTip(False)
rtbBody.Focus()
End Sub
[i]Private Sub PrevTip_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrevTip.Click
'load the next tip NOT random
Previous = True
FillTip(False)
rtbBody.Focus()
End Sub[/i]
Private Sub FillTip(ByVal Random As Boolean)
Try
lblHeading.Image = ilsMain.Images(TipImageIndex).Clone
'choose tip random or next
Static rndRow As Integer
If Random Then
Randomize()
rndRow = Int(((ds.Tables(0).Rows.Count - 1) - 0 + 1) * Rnd() + 0)
[i] ElseIf Previous = False Then
rndRow += 1
Else
rndRow -= 1
End If[/i]
'handle outside of count
If rndRow > ds.Tables(0).Rows.Count - 1 Then rndRow = 0
If rndRow < 0 Then rndRow = ds.Tables(0).Rows.Count - 1
[i] 'Display tip number out of how many tips in titlebar
Me.Text = "Quick Tips - Tip " & rndRow + 1 _
& " out of " & ds.Tables(0).Rows.Count[/i]
Dim dr As DataRow = ds.Tables(0).Rows(rndRow)
lblHeading.Text = dr.Item("Heading")
Try
rtbBody.Rtf = dr.Item("Body")
Catch
'tip is text not rtf
rtbBody.Text = dr.Item("Body")
End Try
Catch eIndex As IndexOutOfRangeException
'there are no tips
lblHeading.Image = ilsMain.Images(ErrorImageIndex).Clone
lblHeading.Text = "There are no tips available!"
rtbBody.Text = "Make sure that there is data in the Tips.xml in the application folder."
Catch ex As Exception
'unknown error
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected Error")
End Try
End Sub
-
Jan 22nd, 2003, 05:31 PM
#11
Thank you very much I'll update the sample with a thank you on my website. I noticed the # of # from the screen of your app and thought that was a good idea, too.
-
Jan 22nd, 2003, 05:35 PM
#12
Thread Starter
Hyperactive Member
You wouldn't believe that I only bought VB.NET just before Christmas and didn't even know how to exit an app! I've surprised myself
Last edited by RealNickyDude; Jan 22nd, 2003 at 05:51 PM.
-
Jan 27th, 2003, 06:13 PM
#13
Thread Starter
Hyperactive Member
Edneeis, no matter how many different ways I try, I can't seem to get it to accept RichText, it either gives me errors saying that tags are missing form xml, or it shows the actual tags instead of interperating them.
Any suggestions on how to incorporate RichText into the 'Tip of the Day' would be most useful.
Thanks.
-
Jan 27th, 2003, 06:37 PM
#14
Well I'm not sure what you are doing wrong, it works for me. One thing to remember is that a full rtf document has to be in there not just a paragraph or whatever. This is due to the rtf format having font and misc information stored in the header. If the code is how I showed you then try this tip.xml.
-
Jan 27th, 2003, 06:53 PM
#15
Thread Starter
Hyperactive Member
Thanks Edneeis, i've sussed out what I was doing wrong, I was loading the entire xml document into Wordpad and saving that instead of the individual tips (doh )
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|