Agent-of-Chaos 0 Light Poster

When you use the word 'sample' it means something very specific to a statistician. If you do indeed want a proper sample of your data, you must not truncate it "when the space runs out" because there might be, for instance, something that only shows up in the late evening, or when a particular user is logged in or ...

Instead, what you must do is store all the data, perhaps locally, then take a proper random sample from that full amount. OR you can properly save one item at a time based on a true random process, and accept that you usuall will get a count that is not exactly 100. What is special about 100?

Of course if you simply want to get 100 items, you can do something much simpler: Accept data only from one node, and stop when you've seen 100.

no i need samples from all nodes, lets say if i have 5 nodes then each node should save only 20 samples to db 20*5 = 100
As i mentioned earlier an upper counter is the simplest solution on each node, but i can not have that logic here.
the control of node is not in my hand. consider it like a black box. i have feed the code script now the script needs to take decision at run time whether to store results in db or not.
some logic mixing with some random number and the time???

Agent-of-Chaos 0 Light Poster

Why would checking the row count crash your DB?
You could create a trigger which checks BEFORE INSERT that the row count does not exceed your maximum and reject the INSERT if it does.
How to reject a row in a trigger: http://forums.mysql.com/read.php?99,134466,134481#msg-134481

a single node is basically processing thousands of samples a day, for each sample then i have to connect with db to check if the row count is still less than 100 this would crash my db because at the same time other nodes are also working. and this check has to be done whether to store or not instead of having 100 samples in db. for all other process this check is failed each time.

For a trigger will work when i am trying to insert, and for insert i need to connect.. so i am again connecting with db?

Agent-of-Chaos 0 Light Poster

Hi to all,

Problem Statement:
I have 4 nodes which are executing in parallel, each node is processing some information and storing records in MySQL DB, the possible records being saved in an db daily is above thousand, but i want only 100 samples to be stored in db daily, i need some logic (mixing with and ip would help?) which permit me whether to store in database or not.. i do not want to connect with db again and again to check whether the row count is 100 or not, that would certainly crash my db. one thing more 4 nodes are in middle layer (mean four nodes are running independently, one node does not know the state of other node), if it is on upper layer then there was no problem at all i would just put a counter in start and then check if counter is below 100 then store else do not store.

Please any help in this is appreciated.

Thanks:)

Agent-of-Chaos 0 Light Poster

hi i am writing a program that reads integers(signed or unsigend) from file.
my input file contains these numbers(without brackets)
[41 35 -66 -124 -31 108 -42 -82 82 -112 73 -15 -15 -69 -23]

and my code is:

#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
main()
{
FILE * hFile;
int c; 
long n  = 0;
hFile = fopen("input15Numbers.txt", "r");
if (hFile == NULL)
{
     printf("Failed to Open the File");
}
else
{
while (!feof(hFile)) {
      c = fgetc (hFile);
      if (c != ' ')
      {
         fscanf (hFile, "%i", &c);
         printf("%i", c);
         printf("\n");
         }


fclose(hFile);

getch();
}
}

But it produce wrong out put when i print it..
Output:
1
5
66
124
31
0
-42
82
2
112
3
15
15
69
23

printing some values correctly but not all, what i am doing wrong here????

Agent-of-Chaos 0 Light Poster

hi,
i have this function..

Sub DrawScreen(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
        Dim myPen As Pen
        myPen = New Pen(Color.Blue, 2)
        Dim gr As System.Drawing.Graphics = e.Graphics
        gr.DrawRectangle(myPen, 1 + x + (i * 4), y + (j * 4), 1 + x + (i * 4) + 3, y + (j * 4) + 3)
        Timer1.Start()
    End Sub

and i have to call it like this DrawScreen() from another function but the comipler is throwing error like this..

Error: Argument not specified for parameter 'e' of 'Public Sub DrawScreen(sender As Object, e As System.Windows.Forms.PaintEventArgs).

so please help me in making above function argument less... or tell me the way to call this function with arguments??????????

Agent-of-Chaos 0 Light Poster

basically i am making chip 8 emulatorfor easy games like maze, ping pong, tic tac, which requires some display..obviously.. the X and Y cordinates are coming to me through OPCODES of Game ROM.. i have to draw them... please read my this thread if you can help me...
http://www.daniweb.com/forums/thread280993.html

also this link...
http://www.xtremevbtalk.com/showthread.php?t=315712

Agent-of-Chaos 0 Light Poster

Hi,
You mentioned:


Yes, It will affect your code with this error:

So, That's not an option.

so whats an OPTION Respected sir????? how can i just convert 4 line of code to VB.Net??? please help me.. giv some code help..

Agent-of-Chaos 0 Light Poster

thanks for your reply...
yes i know that i have to use GDI+.. so i have come up with this..

Public Sub Form1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs)
        Dim g As Graphics = e.Graphics
    End Sub

   
    Protected Sub DrawScreen(ByVal pe As PaintEventArgs)
        Dim pt1 As New Point(1 + x + (i * 4), y + (j * 4))
        Dim pt2 As New Point(1 + x + (i * 4) + 3, y + (j * 4) + 3)
        Dim RGB As New Point(0, 0)
        Dim g As Graphics = pe.Graphics
        Dim pn As New Pen(Color.Blue)
        g.DrawLine(pn, pt1 - pt2, RGB)
    End Sub 'OnPaint

now the problem is that RGB has three cordinates like RGB(0, 0 , 0), as Point can have only two cordinates poit(x,y) so i have force my self to make it RGB(0,0)... does it effect my code???? any solution of it???

the big problem is i have to call this function from other function which is called DrawSprite()..

sub drawSprite()
....
...
DrawScreen()

end sub

here i am calling it by having no argument passed in DrawScreen() function which generates error as i have declared arguments above in the function "ByVal pe As PaintEventArgs", so how i am going to call this function?????? pls reply quick i have only this day left...

and lastly how i am going to use "BF" in above code which is used for fillbox, wht is the alternative of it in vb.net???

Agent-of-Chaos 0 Light Poster

i have this piece of code and i want it to be implemented in vb.net

Sub DrawScreen()
        If Picture1.Point(1 + x + (i * 4), y + (j * 4)) = RGB(c1, c2, c3) Then
            v(&HF) = 1
            Picture1.Line (1 + x + (i * 4), y + (j * 4))-(1 + x + (i * 4) + 3, y + (j * 4) + 3), RGB(0, 0, 0), BF
        Else
            Picture1.Line (1 + x + (i * 4), y + (j * 4))-(1 + x + (i * 4) + 3, y + (j * 4) + 3), RGB(c1, c2, c3), BF
        End If
End Sub

how to imlement this piece of code in vb.net... please i need code of it...urgent

Agent-of-Chaos 0 Light Poster

1. sir please consider this changes also..
declare ram(9016) to ram(4096) because chip 8 requires only 4Kb of memory to run all op codes..

2. stack(256) to stack(16) levels

3. V(256) to V(16) i need only 16 registers of 8 bits each

no need for these functions..
1. DrawScreen_SChip()
2. DrawSChipSprite()
3. ExtendedScreenEnabled()
4. ExtendedSCreenDisabled()
5. ScrollRight()
6. ScrollLeft()
7. ScrollDown

by removing these functions the two functions also changes and that is
1. DrawSprite()
2. Interpret()

Sub Interpret()
    getopcode
    If Check1.Value = 1 Then Text1.Text = Text1.Text + Hex(pc - 2) + ": " + Hex(opcode1) + " " + Hex(opcode2) + " " + Hex(opcode3) + " " + Hex(opcode4) + " -> "
    Select Case opcode1
        Case &H0
            Select Case (opcode3)
                Case &HE
                    Select Case (opcode4)
                        Case &H0:
                            If Check1.Value = 1 Then Text1.Text = Text1.Text + "ClearScreen"
                            ClearScreen
                        Case &HE:
                            If Check1.Value = 1 Then Text1.Text = Text1.Text + "ReturnFromSub"
                            ReturnFromSub
                    End Select
              
            End Select
        Case &H1
            If Check1.Value = 1 Then Text1.Text = Text1.Text + "JumpToAddress"
            JumpToAddress
        Case &H2
            If Check1.Value = 1 Then Text1.Text = Text1.Text + "JumpToSub"
            JumpToSub
        Case &H3
            If Check1.Value = 1 Then Text1.Text = Text1.Text + "SkipIfRegEqual"
            SkipIfRegEqual
        Case &H4:
            If Check1.Value = 1 Then Text1.Text = Text1.Text + "SkipIfRegNotEqual"
            SkipIfRegNotEqual
        Case &H5
            If Check1.Value = 1 Then Text1.Text = Text1.Text + "SkipIfRegEqualReg"
            SkipIfRegEqualReg
        Case &H6
            If Check1.Value = 1 Then Text1.Text = Text1.Text + …
Agent-of-Chaos 0 Light Poster

i am w8ing for ur help and now its almost two days... pls help i have to make this project before monday:-(

Agent-of-Chaos 0 Light Poster

and thanks for providing links... i know very much about chip - 8 now the main thing is to implement it... lets start from keydef???? wht is the best way to assign keydef?? and wht it is keydef(1) = 100 why it is not like keydef(1) = 4? (just for argument)

Agent-of-Chaos 0 Light Poster

firstly thanks for your help..
yeah i know this code and technique is very old.. basically my teacher want me to create a chip-8 emulator and i want to do it on visual basic.. do you help me to improve this code in visual basic step by step???

Agent-of-Chaos 0 Light Poster

hi, i am trying to design chip 8 emulator on visual basic, i have found source code of it but the problem is i am not getting the idea how the code works, i understand some part of it.. please help me.. here is the full source code..

Dim ram(8192) As Byte
Dim stack(256) As Integer
Dim v(256), keydef(16) As Byte
Dim pc, Index, key_choice As Integer
Dim opcode1, opcode2, opcode3, opcode4, sp, key_up, key_down, delaytimer, soundtimer, x, y, i, j, k, c1, c2, c3 As Byte
Dim dbg, Pause, ExtendedScreen As Boolean
Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long

Private Sub About_Click()
    msg = "VB Chip8 - The first Visual Basic implementation" + vbCrLf
    msg = msg + "of a Chip8 Virtual Machine." + vbCrLf
    msg = msg + "Thanks to unknown autor of original C source code." + vbCrLf
    msg = msg + "This release is beta and won't run many games, yet." + vbCrLf
    msg = msg + "Made by VMA in 2004. This is freeware!" + vbCrLf
    MsgBox msg, vbOKOnly, "About VB Chip-8"
End Sub

//it indicates to debug or not
Private Sub Check1_Click()
    If Check1.Value = 1 Then
        Check1.Value = 1
    Else
        dbg = False
    End If
End Sub


Private Sub Command1_Click(Index As Integer)
    key_choice = 0
    Label1.Caption = "Waiting for key..."
    While key_choice = 0
        DoEvents
    Wend
    keydef(Index + 1) = key_choice
    Command1(Index).Caption = Chr(key_choice)
    Label1.Caption = ""
End Sub

Private Sub Exit_Click()
    End …
Agent-of-Chaos 0 Light Poster

Please why you are not helping me, i dont have time coz i have to present my project on 3rd sep please reply me today please please.......

Agent-of-Chaos 0 Light Poster

hi i am making pos system i am using msflexgrid.. and i have make combo box visible when user clicks on grid... i have data combo which contains all supplier company name.... now my problem is that i want to load the combo box with relevant products as user selects Supplier company name...i dont want to show all products... i only want to load the products whos supplier name = dataCmbo.Text and the most important i want to do it by using Adodc...
what i am doing is this(See in picture)...when programs load it does not give any error but it also dont add any record in combo box also.. please help me as early as possible it is urgent.
there is some problem in sql statement of adodc please figure it out.
(Please Check attachments)

my code to load combo is this..

Dim vrnt As Variant
            With Adodc4.Recordset
             Do While Not .EOF
            vrnt = ![Product_Name]
            If IsNull(vrnt) Then vrnt = ""
            Combo1(0).AddItem CStr(vrnt)
            .MoveNext
            Loop
         End With
Agent-of-Chaos 0 Light Poster

Thanks Friends...this problem is solved ....... i have now one more problem see my new thread please please please.

Agent-of-Chaos 0 Light Poster

i takes the current date value and then save it to text1.text

Text1.Text = Format(Now, "m/dd/yyyy")

then i am passing Text1.Text which actually contains date to Sql String which Delets all record that matches the Expiry date.. if current date = expiry date then delete that record..

strSQL = "DELETE * FROM Product WHERE Expiry_Date = '" & Text1.Text & "'"

but it gives error incorrect syntax near the keyword * and some time incorrect syntax near the keyword Delete

Agent-of-Chaos 0 Light Poster

thanks for your reply....
yes user desire to create new shipping receipt...i have auto incremented value receiptID in SQL server database...i have placed a text box field on form that get value of new row in database mean receipt id...but i am using Adodc.recordset.addnew which clear all text fields when form is open...i want that it clear all fields but except receiptID.text field...if you have solution for this it will solve my problem. waitnig for your help...

Agent-of-Chaos 0 Light Poster

hi i have a simple problem i am creating purchase order form in vb.. i want to show incrementd value to user in text field every time user creates new order.....storing this in data base is not a problem for me but the problem is how i auto increment at run time and even program is re-compiled its value does not reset to 0.

Agent-of-Chaos 0 Light Poster

Select [field 1], [field 2], from [your table name].
Note: replace field1 and field 2 by your desired column name.
i think you are using "*" which picks all record in a table so use above statement instead.

Agent-of-Chaos 0 Light Poster

Hi... it seems that it is precedence problem of operations....you are not using parenthesis when you are performing two operations at the same time subtraction and addition... do it this way int sum2 = (numX - numY) + numZ; hope it is going to solve your problem.

Agent-of-Chaos 0 Light Poster

hi vb5programmer.... thanks for your kind help ok i am going to google it again ...i hv google it also but cant find the solution thats why after disappointment i post my problem here :-(

Agent-of-Chaos 0 Light Poster

hi i am making point of sale system.. i want to make empty grid and i want to add list box in first cell of each row, that list box contain items name so that when user select item all other cell of that row is filled by the respective data...for example i want to show 4 fields in grid ItemName, itemprice, Tax, Amount

so when user select item then its price and quantity should automatically be filled in respective cells and in last cell amount is clculated automatically.. if item price is 10 and quantity is 5 then amount fiels contain 50 but how can i work with grid???
need urgent help please guide me step by step...

Agent-of-Chaos 0 Light Poster

thanks for response..
code is fine but it produce some sound when i press enter key and my problem is solved now... i google it and find this code which avoid making sound when user press enter key

If KeyAscii = vbKeyReturn Then KeyAscii = 0
End If

Agent-of-Chaos 0 Light Poster

i am usng key ascii 13(Enter key) to move between text fields... but the problem is that it produce some sound i dont want that it produce that sound, can any one know how to avoid the beep in vb6?????

Private Sub Text1_KeyPress(KeyAscii As Integer)
On Error Resume Next
If KeyAscii = 13 Then
Text2.SetFocus
End If
End Sub

Agent-of-Chaos 0 Light Poster

hi to all genius,
i am making invoice form in vb6, i have to make grid like view so that user can add item details in row just by clicking on it and new Grid is open to select record from it. hope u r understanding..
example:
this is the table in invoice form with these fields
...............................................................................
item name: item description: unit price: amount:
...............................................................................
Row1
----------------------------------------------------------------
Row2
----------------------------------------------------------------
(should i use table or grid here?)

now when i click on Row 1 a seprate form should be open to select record from grid. this is not the problem for me(seprate form) the problem is above table....should i use grid???? but if i use grid it shows the records present in it...i want empty grid so that user can add record from it...and the drop it
please see the image file if you dont understand what i want to explain.

Agent-of-Chaos 0 Light Poster

hi;
my problem is solved by using vbModal actually the problem is in the installation of VB6 i have re-install it now the problem is solved, because in first attempt vb6 was installed with some errors. thanks for all of your help.

Agent-of-Chaos 0 Light Poster

thanks for your help; but when i used vbModal debug gives error that object not found vbModal any suggestions??

Agent-of-Chaos 0 Light Poster

hi i am new to visual basic and i am using vb6, i have senior year project for invenotry managment system..my problem is that if one form is open then the user must not b able to peform other functions(open another form, close application etc) unless the current form is get closed please help me in this