|
I am building a dice game, with rotating dice. The dice will have 1-6 dots on each side. I am also building a class to play the game, but can't figure out how to send a message to roll the dice in the class without the class knowing about the simulating rolling dice, how is this done?
I am avidly interested in graphics and ado.net
|
|
|
|
|
Some code samples would be helpful. Since we can't see your design, there is no way we can tell you what your doing right or wrong.
RageInTheMachine9532
|
|
|
|
|
I am just trying to get started!
|
|
|
|
|
First, what do you mean by "roll the dice in the class without the class knowing about the simulating rolling dice"?
Does this mean that you have 2 seperate classes, something that is displaying graphics dice and something else that actually picks the numbers that the dice will show? Is this a user control you've written to display the dice?
RageInTheMachine9532
|
|
|
|
|
class dice
dim adie1 as int16
dim adie2 as int16
property die1 as int16
get
return adie1
end get
set
sdie1=value
end set
'What I am trying to is to make sure that the class is self-contained'
' it can roll the die on the form and count the value of the die
private function count_die (die1 as int16, die2 as int 16)as int16
dim total as int16
total=die1+die2
return total
public sub getFirstRoll (die1 as int16, die2 as int16)as int16<-- returns array
dim firstroll()as int16
redim firstroll(rolls)
firstroll(rolls)= count_die(die1,die2)
rolls=rolls+1
return firstroll
'test rolls!
I am avidly interested in graphics and ado.net
|
|
|
|
|
If you have a visual component that display rotating dice, you might want to consider building your class into a UserControl (Windows Control Library). That way, you can put your dice logic and visual elements in one place instead of having to worry about synchronizing two seperate classes.
RageInTheMachine9532
|
|
|
|
|
Heres some code that may point you in the right direction. It is Airware so the syntax will not be correct:-
Class DiceDisplay
Property Display as PictureBox
Property NoOfDice as int16
Property Pips as int16
Public Sub RollEm
Dim Roller as DiceRoller(NoOfDice, Pips)
Roller.Roll
DrawDice(Roller)
End Function
Public Sub DrawDice(ByRef Results as DiceRoller)
Dim Index as Int16
For Index = 1 to NoOfDice
DrawDiceImage(Roller.Results(Index))
Next Index
End sub
End Class
Class DiceRoller
Property Results as arraylist
Public Sub Roll(ByVal NoOfDice as int16, ByVal Pips as int16)
Dim Index as int16
For Index = 1 to NoOfDice
Results.Add(convert.toint16(rnd(Pips)))
Next Index
End Sub
End Class
Definitely a PEBCAK! (Problem Exists Between Keyboard And Chair)
My first ASP.Net site is now up http://www.redravenrpg.com
|
|
|
|
|
I have a problem with vb 6.0.
On a form I have put a bound datagrid control - used to list various items from a table stored in an Access database.
Among these items are graphics (company logos) - and I would like to use the DBpix control to display these logos - together with name, adresses etc.
In general - is it possible to have a bound control inside the datagrid, so that the control can be activated for each record in the underlying table ?
Blom Eng.
|
|
|
|
|
this may sound really basic and i'm sure it is. but throughout all of the books i've read (being self taught) i've never come across how to get the string in a text box on one form another text box/label/whatever on another form.
for example:
say form1 has a textbox for inputting a users name. how can i then display that name on form2 in a label control?
thanks in advance
cheers
|
|
|
|
|
xtremean wrote:
i've never come across how to get the string in a text box on one form another text box/label/whatever on another form.
That's because your thinking about the code on one form directly manipulating the controls on another form. The reason you don't see that in the books is because it's bad practice.
What you should be thinking about is having public variables somewhere that both forms can access. For example, you have two forms, one has a string that needs to be passed to the second. The first form just has a label, a textbox and a button on it:
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim newForm As New Form2
newForm.strDataThisFormNeeds = TextBox1.Text
newForm.Show()
End Sub
End Class
Form1 is simple, just type something in the textbox and click a button to send the string to Form2. The code in the button click just creates a new instance of Form2 and set the public variable that Form2 exposes to the string in Form1's textbox. Form2 just has a label and a textbox on it and exposes a public string like this:
Public Class Form2
Inherits System.Windows.Forms.Form
Public strDataThisFormNeeds As String
Private Sub Form2_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
TextBox1.Text = strDataThisFormNeeds
End Sub
End Class
This is just a VERY simple example and does NOT show all the possible methods of passing data between forms!
RageInTheMachine9532
|
|
|
|
|
It's a small but curious question.
All my linkbutton in design page has disappeard on runtime,but in design page and .ASCX file they are there.They are put in a table.
such as
<table id=table1 runat=server><br />
<tr><br />
<Td><br />
<asp:LinkButton id="cmdCreateArticle" Runat="server" CssClass="CommandButton">新文章</asp:LinkButton><br />
</td><br />
</tr><br />
</table>
Thank you in advance.
|
|
|
|
|
I see you have chinese characters? Are they images or text? If they are images you may need to check your path. If they are characters then you the web page may not be referencing the character set.
The other possiblilty I see is that the cssClass is commandbutton. It may be worth trying to change the name as that may be a reserved word. Finally take the CssClass Tag out and see if the characters appear. If they do the style is blank or your '<link' tag="" at="" the="" top="" of="" your="" page="" may="" need="" changing.="" from="" '..="" ..="" styles'="" to="" 'http:="" localhost="" etc.=""
definitely="" a="" pebcak!="" (problem="" exists="" between="" keyboard="" and="" chair)<br="">My First ASP.Net site is now up http://www.redravenrpg.com
|
|
|
|
|
Hi
I'm using toolbar and I've added some icons to my toolbar buttons with the following code
<br />
Dim myImageList As New ImageList<br />
Dim myImage As Image<br />
<br />
myImage = Image.FromFile("C:\Temp\dvd03.ico")<br />
myImageList.Images.Add(myImage)<br />
myImage = Image.FromFile("C:\Temp\dvd01.ico")<br />
myImageList.Images.Add(myImage)<br />
<br />
Me.ToolBar1.ImageList = myImageList<br />
Me.tbb_Scan.ImageIndex = 0<br />
Me.tbb_show.ImageIndex = 1<br />
My Icons are 48x48 so I've set the toolbar button size property as follow :
<br />
Me.ToolBar1.ButtonSize = New System.Drawing.Size(48, 48)<br />
The problem is when I run my application my buttons are very small somthing like 16x16 pixels
Where I am wrong ?
Is it so late so that I need to go bed (22 H GMT !!)
Another question : How to specify to load image in a folder that is in the current folder. (p ex: appname.exe is in c:\Temp and I want all my image in c:\Temp\Images). Or is it possible to include them in the exe file so I don't need to distribute them !
Thx
Sybux
|
|
|
|
|
I am just answering ur second question.
You can get the current folder which has the exe by Application.Startup property like this
myImage = Image.LoadFrom(Application.StartupPath + "\Images\imgName.bmp").
You can attach the images with ur assembly itself.
For doing so, do the following steps.
You add all the image files to the project by right clicking the project
and add existing items.
Select all files and press F4 to open the Properties window. Change Build Action property to Embedded Resource.
Then make the DefaultNamespace if u want (Assume here "MyNamespace")
You can get the images from assembly like this.
Dim a as Assembly = [Assembly].GetExecutingAssembly()
Dim s as Stream = a.GetManifestResourceStream("MyNamespace.urImage1.bmp")
Dim bmp as New Bitmap(s)
|
|
|
|
|
Thx for answer now it's working with the Assembly method but If I can correct you, here is the working code :
<br />
Dim myAssembly As System.Reflection.Assembly<br />
Dim myStream As System.IO.Stream<br />
Dim myImage As Image<br />
<br />
myAssembly = System.Reflection.Assembly.GetExecutingAssembly<br />
' The resource name is Case Sensitive !<br />
myStream = myAssembly.GetManifestResourceStream("myProjectName.icon1.ICO")<br />
myImage = Image.FromStream(myStream)<br />
Does any1 know with my little icon (48x48) are small in my toolbar ?
|
|
|
|
|
Thanks for ur correction.
You have to set the Button Size as well as the ImageList's ImageSize property.
By default its value is 16 by 16.
|
|
|
|
|
Hi, i have a big question i think ! How i can make a communication with a casio cash registers device with a computer program using visual basic.net (or any other language !), please if there is any API for this purpose tell me please !!
|
|
|
|
|
No API built into the .NET Framework or Win32, but you might want to get the docs on the cash register. If the cash register has a serial port on it, and you have sufficient docs on what the register understands, you might be able to write your own communication class for the register.
RageInTheMachine9532
|
|
|
|
|
You can communicate with some models of casio electronic cash register (ECR) using serial communications.
When I say some, I believe that certain models require an aditional comms board to be fitted.
You will also require the protocol manual for the specific model of ECR to understand the format of the data to send.
An understanding of how to manually program the ECR would help you understand the protocol manual.
If you have no experience of this technology then you probably have a steep learning curve ahead.
Have you climbed the north face of the Eiger?
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
LearnVisualStudio.Net
|
|
|
|
|
Hi,
I'm creating a little application with multiple screen but I don't want to user MDI window.
So I've got the idea to use TabControl tu design each window I need for my application.
Second Point, I want to change the tab by pressing a button on the main window or by selecting option in the menu.
All is working fine. The next step is to hide the Text Label of each Tab. I haven't find any option in the tabcontrol ot act this way.
Does any1 know how to do this !
Thx
Sybux
|
|
|
|
|
Do you wan't to hide the Text or the Tabs? Text is easy, just don't put in any Text, you'll end up with blank tabs.
Hiding the tabs is a little more complicated. Basically, you can't using standard methods. You could try moving the tabs up off the top of the form, under your menu bar, or, under some other kind of control.
You could probably use some third party tab control that has that functionality, but I don't know of any. Or you could get imaginative and hide the tabs behind another control on the form, even if was just a blank panel control, or something like that.
RageInTheMachine9532
|
|
|
|
|
Thanx for the suggestion. in fact I've found what I was looking for : Panel.
I now use Panel to put all control I need and I use a toolbar with this button to change panels.
panel1.bringtofront() etc....
Bye
Sybux
|
|
|
|
|
While using Excel, I imported text file as an object (imported as OLEObject).
I want to export it back to a text file. I can copy it to the clipboard, but I don't know how to copy it from the clipboard to a path.
|
|
|
|
|
Wouldn't it be alot easier to tell Excel to export the information back to a text file using the SaveAs function? You'd save yourself the work of writing code to go to the clipboard and import the Excel sheet data that's on it (not text!), parse it up to get the text and then write it out to a file.
RageInTheMachine9532
|
|
|
|
|
I checked this option, but it seems that I can't use SaveAs function for OLEObject. Can you write me the code lines of how to save OLEObject (that contains one item - which is text file) to text file? Thanks
|
|
|
|