vb程式 在文字框中輸入點座標(x,y)怎樣從文字框中分離出x,y,並判斷是哪個象限

時間 2021-07-17 07:46:06

1樓:小陳

建議你用兩個文字框,並設定只能輸入數字,這比從一個文字框輸入後進行文字處理要簡單實用很多,在一個文字框錄入可以寫一個分離函式,原理是: 取 ( 到 , 之間的內容為 x 取 , 到 ) 之間的內容 y

一個簡單的例項:

private sub form_load()

dim x as long, y as long, bln as boolean

bln = 取xy值("(32,33)", x, y)

msgbox "(32,33) x=" & x & " ,y= " & y

msgbox 判斷象限(x, y)

end sub

public function 取xy值(byval 要處理的文字 as string, byref x as long, byref y as long) as boolean

dim a as long, b as long, c as long, strx as string, stry as string

a = instr(要處理的文字, "(")

b = instr(要處理的文字, ",")

c = instr(要處理的文字, ")")

strx = mid(要處理的文字, a + 1, b - a)

stry = mid(要處理的文字, b + 1, c - b - 1)

x = clng(strx)

y = clng(stry)

取xy值 = true

end function

public function 判斷象限(x as long, y as long) as string

dim xr as integer, yr as integer

xr = sgn(x)

yr = sgn(y)

select case xr & yr

case "00"

判斷象限 = "原點"

case "01"

判斷象限 = "y正半軸"

case "10"

判斷象限 = "x正半軸"

case "0-1"

判斷象限 = "y負半軸"

case "-10"

判斷象限 = "x負半軸"

case "11"

判斷象限 = "第一象限"

case "-11"

判斷象限 = "第二象限"

case "-1-1"

判斷象限 = "第三象限"

case "1-1"

判斷象限 = "第四象限"

case else

判斷象限 = "出錯了."

end select

end function

2樓:匿名使用者

option explicit

private sub command1_click()dim x%, y%, r$

x = sgn(split(text1, ",")(0))y = sgn(split(text1, ",")(1))select case x & y

case "00"

r = "原點"

case "11"

r = "第一象限"

case "-11"

r = "第二象限"

case "-1-1"

r = "第三象限"

case "1-1"

r = "第四象限"

end select

msgbox "輸入點: (" & text1.text & ") 屬於" & r

end sub

3樓:匿名使用者

dim sst

sst=split(text1.text,",")x=sst(0)

y=sst(1)

然後判斷 x 和y的正負嘍,相信你會搞定的。。

4樓:匿名使用者

private sub text1_change()on error resume next

dim sc, x%, y%, sinfo$sc = split(trim(text1), ",")x = cint(sc(0)): y = cint(sc(1))sinfo = iif(x = 0 and y = 0, "原點", _

iif(x * y = 0, iif(x = 0, iif(y > 0, "y正", "y負"), iif(x > 0, "x正", "x負") & "半軸"), _

"第" & iif(x * y > 0, iif(x > 0, "一", "三"), iif(x > 0, "四", "二")) & "象限"))

me.caption = sinfo

end sub

1,輸入兩個數代表一個點的座標(x,y),然後判斷點(x,y)屬於哪一個象限.用c語言程式設計寫

5樓:匿名使用者

#include

int main()

else if(x < 0)

else

printf("輸入2個整數(空格隔開,q退出):\n");

}return 0;}

6樓:山河不悟

int x,y;

cin>>x>>y;

if(x>0&&y>0)

cout<<"1"<0)

cout<<"2"<0&&y<0)

cout<<"4"<

(用c++編寫程式)輸入平面直角座標系中一點的座標(x,y),判斷改點是在那個象限中或那一條座標軸上

7樓:匿名使用者

include "math.h"

class point

};class line

float getdistance(point p)};void main()

vb文字框1中的字元反序顯示在文字框2中

網海1書生 text2.text strreverse text1.text private sub command1 click dim m as long,t as long,n as integer m val inputbox 輸入大於1的正整數m 輸入資料 n 1 t 0 do while...

VB中如何通過在文字框中輸入時間日期然後直接賦值給系統時間日期,從而達到修改系統時間的目的

這裡的關鍵點是使用isdate 函式判斷輸入的是不是正確的日期時間格式。如果正確,則使用date語句和time語句設定系統的日期和時間。如下 private sub command1 click if isdate text1.text then 設定系統日期和時間 date format cdat...

怎樣用VB做個編寫程式,在文字框中顯示當前系統時間,並隨時間進行變化

你新增一個timer控制元件 interval屬性 100 新增事件 private sub timer1 timer text1.text format now,hh mm ss end sub private sub form load timer1.enabled trueend sub pr...