• Advertisement

Tim Lawton

  • Content count

  • Joined

  • Last visited

Community Reputation

179 Neutral

About Tim Lawton

  • Rank
  1. Hey there,   I've recently made an application to calculate quotes for patio doors and windows given its height/size and other variables, everything is working fine and it prints out the costs/profits/VAT etc onto a rich text box on the application. Now I was wondering if it's possible to get this information onto some kind of printable format which would fit onto an A4 piece of paper (This is for a professional company).   My guess was to design a A4 template which would have logos and such and then enters the values onto the template to create some sort of receipt. My guess is to have something which looks like this generated (http://www.starmicronics.com/files/Image/TSP800II_Hotel_Invoice_1.jpg) just pulled it off google.   I was wondering if this at all possible in VB? If so how would I go about doing this?   Thanks
  2. Thanks SiCrane, worked like a charm!
  3. Hey,   I've just written this code, unfortunately the 'price' & 'price2' variables always returns as 0 when I print it, and I'm really confused why as it should, also instead of it adding the value to price during the if statements, it just goes straight to the last Else which prints out that I should enter a correct numeric value Dim theHeight As String = heightEntry.Text Dim theWidth As String = widthEntry.Text Dim price As Integer Dim price2 As Integer If IsNumeric(theWidth) >= 1800 Then price = 1444 ElseIf IsNumeric(theWidth) >= 1801 And IsNumeric(theWidth) <= 2000 Then price = 1458 ElseIf IsNumeric(theWidth) >= 2001 And IsNumeric(theWidth) <= 2200 Then price = 1479 ElseIf IsNumeric(theWidth) >= 2201 And IsNumeric(theWidth) <= 2400 Then price = 1580 ElseIf IsNumeric(theWidth) >= 2401 And IsNumeric(theWidth) <= 2600 Then price = 1606 ElseIf IsNumeric(theWidth) >= 2601 And IsNumeric(theWidth) <= 2800 Then price = 1630 ElseIf IsNumeric(theWidth) >= 2801 And IsNumeric(theWidth) <= 3000 Then price = 2185 ElseIf IsNumeric(theWidth) >= 3001 And IsNumeric(theWidth) <= 3200 Then price = 2204 ElseIf IsNumeric(theWidth) >= 3201 And IsNumeric(theWidth) <= 3400 Then price = 2259 Else Output("Please Enter Numbers Between 1800 to 3400") End If If IsNumeric(theHeight) > 2100 Then price2 = price * 1.05 Else price2 = price End If Output("Value is: " + price2.ToString) End Sub Any help would be greatly appreciated, thanks!
  4. That makes sense, I am also lead to believe I can't use 'width' as it's a system variable If theWidth >= 1801 And theWidth <= 2000 Then price = 1458 End If This seems to be working fine now, cheers
  5. Hey there,   trying to create a simple application which can calculate quotes based on the size of a variable, but having a bit of trouble as I havnt touched Visual Basic in over 5 years.   So far I have this If width >= 1801 And <= 2000 Then price = 1458 End If is the width is equal to or larger than 1801 and the width is greater than or equal to 2000 then the price is 1458, although this is saying that the 2nd operator is infact an XML element?   Does anyone have an example of a working if statement like this that I can get an idea of?   Cheers
  6. Hey there,   started to create a game in XNA in my spare time, its a 2D platform game. I'm trying to get a similar effect to a game such as Terraria, where the camera is centralized around the player's character/avatar.   Is there any tutorials out there which can explain how this is done in XNA?   Thanks in advanced
  7. Which part didn't you understand? How to code these error checks you speak of as mine isn't getting the job done
  8. I'm unsure how to create these advance ways of error checking, I've put watches on the variables and they all seem to be taking in the expected values, still, there is no networking. I've used very very similar code before on another project, which was transferring only x,y values.   So all I've done is added a z value to the struct, and its not working 
  9. Can't you offer me some sample code, I don't understand fully what you mean
  10. Wonderful, thanks so much :)
  11. Upon adding that error checking method to my other networking application using similar code, it also caused my server to no longer receive updates on the client's position, so I have removed that. Does anyone know why this isn't working, its really starting to bug me :/
  12. While debugging it this code returned false   r = WSAStartup(MAKEWORD(2,2), &Winsock); if(!r) {return false;} which would suggest the socket isnt being made and I have no idea why tho
  13. Hey there,   I've rendered 4 zones which have an x,y,z coordinate and are all 100.0f by 100.0f and completely flat across the 'z' axis, resulting in this:    Now, I have a struct which holds the coordinates of a player in 3D space struct PLAYER { float x, y, z; }; PLAYER Player   and I want to check if the player's coordinates are inside the more or less 2D grid, it doesn't need to check against the y axis as the player can not move up or down the y axis.   The problem is my CheckZone() function I am trying to create, so far it looks like this, but I'm struggling to work to this as I on a basic level for programming:   void Application::CheckZone() { Player = {Player.x, Player.y, Player.y}; float Section1[4][2] = { {0.0f, 0.0f}, {0.0f, 80.f}, {80.0f, 0.0f}, {80.0f, 0.0f} }; if(Player == Section1[][]) { //Trigger element in Section1 }   I'm getting "Error: expected an expression" from the 2 array boxes in the if statement, as well as the Player statement, I'm having trouble understanding some basic programming here, any help would be greatly appreciated      EDIT: On closer inspection the title can be mis-leading, I'm not trying to check an object against an object, instead the coordinates for the grid which are decoupled from these arrays.
  14. hmm, whats a better way of testing these functions then? Can you give me some sample code, if not too much trouble, please
  15. This is the updated functions to check for errors:   CLIENT bool Application::Init_Winsock() { bool r; r = WSAStartup(MAKEWORD(2,2), &Winsock); if(!r) {return false;} if(LOBYTE(Winsock.wVersion) !=2 || HIBYTE(Winsock.wVersion) !=2) //Check version { WSACleanup(); //Cleanup and return false if version is wrong return false; } //Create Socket Socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); //Input Receiver Information ZeroMemory(&RemoteAddress, sizeof(RemoteAddress)); //Clear Struct RemoteAddress.sin_family = AF_INET; //Set the Address Family RemoteAddress.sin_addr.s_addr = inet_addr(SERVER_ADDRESS); //Set IP Address RemoteAddress.sin_port = SERVER_PORT; //Set Port return true; } bool Application::Send_Packet(PLAYER* data) { bool r; r = sendto(Socket, (char*)data, sizeof(PLAYER), 0, (sockaddr*)&RemoteAddress, sizeof(sockaddr)); if(!r) {return false;} return true; }   The client is sending the updated version of the Player Struct every frame, using the update function be called by the Win32 class. bool Application::Update() { bool r; //Read user input r = m_Input->Update(); if(!r) {return false;} //Chcek for Escape if(m_Input->IsEscapePressed() == true) {return false;} //Update System m_Timer->Update(); //Update Input r = HandleInput(m_Timer->GetTime()); if(!r) {return false;} //Update Networking Send_Packet(&Player); //Send packets to server //Render Graphics r = RenderGraphics(); if(!r) {return false;} return true; }         SERVER bool Application::Init_Winsock() { bool r; r = WSAStartup(MAKEWORD(2,2), &Winsock); if(!r) {return false;} if(LOBYTE(Winsock.wVersion) !=2 || HIBYTE(Winsock.wVersion) !=2) //Check Version { WSACleanup(); //Cleanup and end if not version 2 return false; } //Create Socket Socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); //Input Reciever Information ZeroMemory(&RemoteAddress, sizeof(RemoteAddress)); //Clear Struct RemoteAddress.sin_family = AF_INET; //Set the Family Address RemoteAddress.sin_port = SERVER_PORT; //Set Port r = bind(Socket, (sockaddr*)&RemoteAddress, sizeof(RemoteAddress)); if(!r) {return false;} //Start the recieve thread r = CreateThread(NULL, 0, RecvThread, (void*)this, 0, NULL); if(!r) {return false;} return true; } DWORD WINAPI Application::RecvThread(LPVOID knock) { bool r; Application *instance = static_cast<Application *>(knock); while(true) { PLAYER Recv; r = recvfrom(instance->Socket, (char*)&Recv, sizeof(PLAYER), 0, (sockaddr*)&instance->RemoteAddress, &instance->SizeInt); if(!r) {return false;} instance->Player = Recv; } }
  • Advertisement